Edit this page
Report an issue
14:15-15:00
July 12, 2023
View slides in full screen
Repeat the daily electricity example, but instead of using a quadratic function of temperature, use a piecewise linear function with the “knot” around 20 degrees Celsius (use predictors Temperature & Temp2). How can you optimize the choice of knot?
Temperature
Temp2
The data can be created as follows.
vic_elec_daily <- vic_elec |> filter(year(Time) == 2014) |> index_by(Date = date(Time)) |> summarise( Demand = sum(Demand)/1e3, Temperature = max(Temperature), Holiday = any(Holiday) ) |> mutate( Temp2 = I(pmax(Temperature-20,0)), Day_Type = case_when( Holiday ~ "Holiday", wday(Date) %in% 2:6 ~ "Weekday", TRUE ~ "Weekend" ) )
Repeat Lab Session 18 but using all available data, and handling the annual seasonality using Fourier terms.