# MEFM v2.2

## Monash Electricity Forecasting Model

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.

## Readme

#MEFM package

The R package *MEFM* 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 demographical and economical data; public holiday data. The formats of the required data are described in the help files.

Some documentation of the underlying model is provided at http://robjhyndman.com/working-papers/mefm/

## Installation

You can install the latest version from Github

```
# install.packages("devtools")
library(devtools)
install_github("robjhyndman/MEFM-package")
```

## Usage

```
library(MEFM)
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")
```

## License

This package is free and open source software, licensed under GPL (>= 2).

## Functions in MEFM

Name | Description | |

MEFM-package | Monash Electricity Forecasting Model | |

seasondays | The number of days in a season | |

demand_model | Estimate the electricity demand models | |

sa.econ | Historical demographic & economic data for South Australia | |

sa | Historical data for model estimation | |

maketemps | Create lagged temperature variables | |

simulate_ddemand | Temperature and demand Simulation | |

simulate_demand | Simulate the electricity demand for the next season | |

No Results! |

## Details

Type | Package |

Date | 2016-06-01 |

License | GPL (>=2) |

LazyData | yes |

LazyLoad | yes |

depends | forecast , R (>= 2.14.0) , splines |

Contributors | Shu Fan, Rob Hyndman |

#### Include our badge in your README

```
[![Rdoc](http://www.rdocumentation.org/badges/version/MEFM)](http://www.rdocumentation.org/packages/MEFM)
```