| Title: | Monash Electricity Forecasting Model |
|---|---|
| Description: | This package includes a set of tools for implementing the Monash Electricity Forecasting Model for electricity demand. The package requires the following data as input: half-hourly/hourly electricity demands; half-hourly/hourly temperatures at one or two locations; seasonal demographical and economical data; public holiday data. The formats of the required data are described in the help files. |
| Authors: | Rob Hyndman [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-2140-5352>), Shu Fan [aut] |
| Maintainer: | Rob Hyndman <[email protected]> |
| License: | GPL (>=2) |
| Version: | 2.2 |
| Built: | 2026-05-17 07:22:37 UTC |
| Source: | https://github.com/robjhyndman/MEFM-package |
This package includes a set of tools for implementing the Monash Electricity Forecasting Model based on the paper by Hyndman and Fan (2010).
The package requires the following data as input: half-hourly/hourly electricity demands; half-hourly/hourly temperatures at one or two locations; seasonal demographic and economic data; public holiday data. The formats of the required data are described in the help files.
Rob J Hyndman and Shu Fan.
Maintainer: Rob J. Hyndman <[email protected]>; Shu Fan <[email protected]>
R. J. Hyndman and S. Fan (2010) "Density Forecasting for Long-term Peak Electricity Demand", IEEE Trans. Power Systems, 25(2), 1142–1153. http://robjhyndman.com/papers/peak-electricity-demand/
R. J. Hyndman and S. Fan (2014) "Monash Electricity Forecasting Model" Version 2014.1. http://robjhyndman.com/working-papers/mefm/
# formula for half-hourly model, to be given by the user formula.hh <- list() for(i in 1:48) formula.hh[[i]] = as.formula(log(ddemand) ~ ns(temp, df=2) + day + holiday + ns(timeofyear, 9) + ns(avetemp, 3) + ns(dtemp, 3) + ns(lastmin, 3) + ns(prevtemp1, df=2) + ns(prevtemp2, df=2) + ns(prevtemp3, df=2) + ns(prevtemp4, df=2) + ns(day1temp, df=2) + ns(day2temp, df=2) + ns(day3temp, df=2) + ns(prevdtemp1, 3) + ns(prevdtemp2, 3) + ns(prevdtemp3, 3) + ns(day1dtemp, 3)) # Formula for annual model, to be given by the user formula.a <- as.formula(anndemand ~ gsp + ddays + resiprice) # Create lagged temperature variables sa <- maketemps(sa,2,48) sa.model <- demand_model(sa, sa.econ, formula.hh, formula.a) summary(sa.model$a) summary(sa.model$hh[[33]]) # Simulate future normalized half-hourly data simdemand <- simulate_ddemand(sa.model, sa, simyears=10) # Seasonal economic and weather forecast, to be given by user afcast <- data.frame(pop=1694, gsp=22573, resiprice=34.65, ddays=642) # Simulate half-hourly data demand <- simulate_demand(simdemand, afcast) # Illustrate the results plot(density(demand$annmax, bw="SJ"), main="Density of seasonal maximum demand", xlab="Demand")# formula for half-hourly model, to be given by the user formula.hh <- list() for(i in 1:48) formula.hh[[i]] = as.formula(log(ddemand) ~ ns(temp, df=2) + day + holiday + ns(timeofyear, 9) + ns(avetemp, 3) + ns(dtemp, 3) + ns(lastmin, 3) + ns(prevtemp1, df=2) + ns(prevtemp2, df=2) + ns(prevtemp3, df=2) + ns(prevtemp4, df=2) + ns(day1temp, df=2) + ns(day2temp, df=2) + ns(day3temp, df=2) + ns(prevdtemp1, 3) + ns(prevdtemp2, 3) + ns(prevdtemp3, 3) + ns(day1dtemp, 3)) # Formula for annual model, to be given by the user formula.a <- as.formula(anndemand ~ gsp + ddays + resiprice) # Create lagged temperature variables sa <- maketemps(sa,2,48) sa.model <- demand_model(sa, sa.econ, formula.hh, formula.a) summary(sa.model$a) summary(sa.model$hh[[33]]) # Simulate future normalized half-hourly data simdemand <- simulate_ddemand(sa.model, sa, simyears=10) # Seasonal economic and weather forecast, to be given by user afcast <- data.frame(pop=1694, gsp=22573, resiprice=34.65, ddays=642) # Simulate half-hourly data demand <- simulate_demand(simdemand, afcast) # Illustrate the results plot(density(demand$annmax, bw="SJ"), main="Density of seasonal maximum demand", xlab="Demand")
Estimate the half-hourly/hourly and seasonal demand models.
demand_model(hhdata, adata, hhoptformula, aoptformula)demand_model(hhdata, adata, hhoptformula, aoptformula)
hhdata |
The historical half-hourly/hourly demand, temperature and seasonality data |
adata |
The historical seasonal (annual, summer, winter or quarterly) demographic and economic data |
hhoptformula |
The formula for each half-hourly/hourly demand model |
aoptformula |
The formula for seasonal demand model |
Estimate the demand model using the historical data, use additive model for half-hourly/hourly demand and linear model for seasonal demand, log demand is used for half-hourly/hourly model.
hh |
half-hourly/hourly demand models |
hhfits |
fitted values of half-hourly/hourly models |
hhres |
half-hourly/hourly model residuals |
a |
seasonal model |
afits |
fitted values of seasonal model |
fits |
fitted values of the entire model |
res |
entire model residuals |
Rob J Hyndman and Shu Fan
R. J. Hyndman and S. Fan (2010) "Density Forecasting for Long-term Peak Electricity Demand", IEEE Trans. Power Systems, 25(2), 1142–1153.
simulate_ddemand,
simulate_demand,
sa,
sa.econ
# formula for half-hourly model, to be given by the user formula.hh <- list() for(i in 1:48) formula.hh[[i]] = as.formula(log(ddemand) ~ ns(temp, df=2) + day + holiday + ns(timeofyear, 9) + ns(avetemp, 3) + ns(dtemp, 3) + ns(lastmin, 3) + ns(prevtemp1, df=2) + ns(prevtemp2, df=2) + ns(prevtemp3, df=2) + ns(prevtemp4, df=2) + ns(day1temp, df=2) + ns(day2temp, df=2) + ns(day3temp, df=2) + ns(prevdtemp1, 3) + ns(prevdtemp2, 3) + ns(prevdtemp3, 3) + ns(day1dtemp, 3)) # formula for annual model, to be given by the user formula.a <- as.formula(anndemand ~ gsp + ddays + resiprice) # create lagged temperature variables sa <- maketemps(sa,2,48) sa.model <- demand_model(sa, sa.econ, formula.hh, formula.a) summary(sa.model$a) summary(sa.model$hh[[33]])# formula for half-hourly model, to be given by the user formula.hh <- list() for(i in 1:48) formula.hh[[i]] = as.formula(log(ddemand) ~ ns(temp, df=2) + day + holiday + ns(timeofyear, 9) + ns(avetemp, 3) + ns(dtemp, 3) + ns(lastmin, 3) + ns(prevtemp1, df=2) + ns(prevtemp2, df=2) + ns(prevtemp3, df=2) + ns(prevtemp4, df=2) + ns(day1temp, df=2) + ns(day2temp, df=2) + ns(day3temp, df=2) + ns(prevdtemp1, 3) + ns(prevdtemp2, 3) + ns(prevdtemp3, 3) + ns(day1dtemp, 3)) # formula for annual model, to be given by the user formula.a <- as.formula(anndemand ~ gsp + ddays + resiprice) # create lagged temperature variables sa <- maketemps(sa,2,48) sa.model <- demand_model(sa, sa.econ, formula.hh, formula.a) summary(sa.model$a) summary(sa.model$hh[[33]])
The function is used to create lagged temperature variables for model estimation.
maketemps(x, temp_sites, periods = 48)maketemps(x, temp_sites, periods = 48)
x |
Data frame including temperature observations from 1 or 2 weather stations |
temp_sites |
The number of weather stations, select between 1 and 2 |
periods |
The periods within a day, choose between 48 (half-hourly data) and 24 (hourly data) |
The complete data frame that can be used for model estimation.
Rob J Hyndman and Shu Fan
R. J. Hyndman and S. Fan (2010) "Density Forecasting for Long-term Peak Electricity Demand", IEEE Trans. Power Systems, 25(2), 1142–1153.
sa <- maketemps(sa,2,48)sa <- maketemps(sa,2,48)
Historical data of South Australia
A data frame with 124848 half-hourly observations on the following 19 variables.
demanda numeric vector containing half-hourly electricity demand for South Australia.
offseta numeric vector containing half-hourly demand from some industrial customers who are not temperature sensitive (e.g., mines and smelters).
timeofdaya numeric vector giving the time of day (0-47).
datea numeric vector giving the date within the month (1-31).
montha numeric vector giving the month (1-12).
yeara numeric vector giving the year (2000-2014).
daya factor with levels Mon Tue Wed Thu Fri Sat Sun
idatea numeric vector giving the date in days since 1 January 1900.
holidaya factor with levels Normal Day before Holiday Day after.
workdaya character vector with values NWD (Non-WorkDay) and WD (WorkDay).
timeofyeara numerical time series giving the time in days since midnight on 1 January of each year.
Yeara numeric time series giving the time in years.
fyeara numeric vector giving the financial year (starting 1 July).
temp1a numeric vector giving the temperature in Celsius at location 1
temp2a numeric vector giving the temperature in Celsius at location 2.
anndemanda numeric vector giving the total demand in each year.
annoffseta numeric vector giving the total offset demand in each year.
ddemanda numeric vector giving the normalized demand (demand/anndemand).
doffseta numeric vector giving the normalized offset (offset/annoffset).
Historical data for South Australia, including half-hourly demand, temperatures from 2 locations, weekday, weekend, and holiday dates. Only data from October-March were retained for summer analysis and modelling.
http://www.aemo.com.au/Electricity/Data/Price-and-Demand/Aggregated-Price-and-Demand-Data-Files
R. J. Hyndman and S. Fan (2010) "Density Forecasting for Long-term Peak Electricity Demand", IEEE Trans. Power Systems, 25(2), 1142–1153.
plot(ts(sa[,"demand"],freq=48*seasondays,start=c(2000,7)))plot(ts(sa[,"demand"],freq=48*seasondays,start=c(2000,7)))
Annual data for South Australia including population, GSP, residential electricity price, total electricity price and cooling/heating degree days
A multivariate time series with the following columns:
State population (thousands of people)
Gross State Product chain volume estimate (in 2008-2009 millions of dollars)
Residential price index (2008-2009 cents per kWh)
Total price (2008-2009 cents per kWh)
Annual electricity demand (GW).
Cooling degree days with a threshold of 18.5 degrees Celsius.
R. J. Hyndman and S. Fan (2010) "Density Forecasting for Long-term Peak Electricity Demand", IEEE Trans. Power Systems, 25(2), 1142–1153.
plot(sa.econ)plot(sa.econ)
The number of days in a season, set to 182 for a summer season.
A "season" is taken to be the period over which a model is estimated. In Hyndman & Fan (2010), the season was 1 November to 31 March and so seasondays=151. The default value in the package is seasondays=182; i.e., six months. The value of seasondays can be changed by the user.
Simulate the half-hourly/hourly temperature and demand
simulate_ddemand(model, hdata, simyears = 1000, delta = 5)simulate_ddemand(model, hdata, simyears = 1000, delta = 5)
model |
The demand models |
hdata |
The half-hourly/hourly demand, temperature and seasonality data |
simyears |
The length of years of simulation |
delta |
The value of blockdays offset limit for bootstrap |
Simulate the half-hourly/hourly temperature and demand using the historical data and the half-hourly/hourly demand model
An object of class simdemand, basically a list including elements
hhfit |
Simulated half-hourly demand |
hhres |
Simulated half-hourly residuals |
ores |
Simulated half-hourly offset demand |
a |
Seasonal model |
Rob J Hyndman and Shu Fan
R. J. Hyndman and S. Fan (2010) "Density Forecasting for Long-term Peak Electricity Demand", IEEE Trans. Power Systems, 25(2), 1142–1153.
demand_model,
simulate_demand,
sa,
MEFM-package for examples.
Simulate the half-hourly/hourly, seasonal peak electricity demand for the next season
simulate_demand(sim, afcast, nyears = length(sim$hhfit)/seasondays/48, periods = 48)simulate_demand(sim, afcast, nyears = length(sim$hhfit)/seasondays/48, periods = 48)
sim |
The simulated half-hourly demand (normalized against seasonal average demand) |
afcast |
The demographic and economic forecasts for the next season |
nyears |
The length of years of simulation |
periods |
The periods within a day, choose between 48 (half-hourly data) and 24 (hourly data) |
Simulate/forecast the half-hourly/hourly, seasonal peak electricity demand for the next season by incorporating the seasonal demographic & economic forecasts (to be provided by the user)
demand |
The forecasted half-hourly demand |
annmax |
The forecasted seasonal maximum demand |
Rob J. Hyndman and Shu Fan
R. J. Hyndman and S. Fan (2010) "Density Forecasting for Long-term Peak Electricity Demand", IEEE Trans. Power Systems, 25(2), 1142–1153.
demand_model,
simulate_ddemand,
MEFM-package for examples.