CommencerCommencer gratuitement

Forecasting electricity demand

You can also model daily electricity demand as a function of temperature. As you may have seen on your electric bill, more electricity is used on hot days due to air conditioning and on cold days due to heating.

In this exercise, you will fit a quadratic regression model with an ARMA error. One year of daily data are stored as elecdaily including total daily demand, an indicator variable for workdays (a workday is represented with 1, and a non-workday is represented with 0), and daily maximum temperatures. Because there is weekly seasonality, the frequency has been set to 7.

Let's take a look at the first three rows:

> elecdaily[1:3, ]
       Demand Temperature Workday
[1,] 174.8963        26.0       0
[2,] 188.5909        23.0       1
[3,] 188.9169        22.2       1

elecdaily has been pre-loaded into your workspace.

Cet exercice fait partie du cours

Forecasting in R

Afficher le cours

Instructions

  • Produce time plots of only the daily demand and maximum temperatures with facetting.
  • Set up a matrix of regressors to include MaxTemp for the maximum temperatures, MaxTempSq which represents the squared value of the maximum temperature, and Workday, in that order. Clearly, the second argument of cbind() will require a simple mathematical operator.
  • Fit a dynamic regression model of the demand column with ARIMA errors and call this fit.
  • If the next day is a working day (indicator is 1) with maximum temperature forecast to be 20°C, what is the forecast demand? Fill out the appropriate values in cbind() for the xreg argument in forecast().

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Time plots of demand and temperatures
autoplot(elecdaily[, c(___, ___)], facets = ___)

# Matrix of regressors
xreg <- cbind(MaxTemp = elecdaily[, "Temperature"],
              MaxTempSq = ___,
              Workday = ___)

# Fit model
fit <- auto.arima(___, xreg = xreg)

# Forecast fit one day ahead
forecast(___, xreg = cbind(___, ___, ___))
Modifier et exécuter le code