Giter Club home page Giter Club logo

mefm-package's Introduction

#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 robjhyndman.com/publications/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).

mefm-package's People

Contributors

robjhyndman avatar shufan0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mefm-package's Issues

Convert to dplyr mutate code

x$prevdtemp1 <- c(rep(NA,1),x$dtemp[1:(n-1)])
x$prevdtemp2 <- c(rep(NA,2),x$dtemp[1:(n-2)])
x$prevdtemp3 <- c(rep(NA,3),x$dtemp[1:(n-3)])
x$prevdtemp4 <- c(rep(NA,4),x$dtemp[1:(n-4)])
x$prevdtemp5 <- c(rep(NA,5),x$dtemp[1:(n-5)])
x$prevdtemp6 <- c(rep(NA,6),x$dtemp[1:(n-6)])
x$day1dtemp <- c(rep(NA,periods),x$dtemp[1:(n-periods)])
x$day2dtemp <- c(rep(NA,2*periods),x$dtemp[1:(n-2*periods)])
x$day3dtemp <- c(rep(NA,3*periods),x$dtemp[1:(n-3*periods)])
x$day4dtemp <- c(rep(NA,4*periods),x$dtemp[1:(n-4*periods)])
x$day5dtemp <- c(rep(NA,5*periods),x$dtemp[1:(n-5*periods)])
x$day6dtemp <- c(rep(NA,6*periods),x$dtemp[1:(n-6*periods)])
}
# Create lagged versions of temp variables
x$prevtemp1 <- c(rep(NA,1),x$temp[1:(n-1)])
x$prevtemp2 <- c(rep(NA,2),x$temp[1:(n-2)])
x$prevtemp3 <- c(rep(NA,3),x$temp[1:(n-3)])
x$prevtemp4 <- c(rep(NA,4),x$temp[1:(n-4)])
x$prevtemp5 <- c(rep(NA,5),x$temp[1:(n-5)])
x$prevtemp6 <- c(rep(NA,6),x$temp[1:(n-6)])
x$day1temp <- c(rep(NA,periods),x$temp[1:(n-periods)])
x$day2temp <- c(rep(NA,2*periods),x$temp[1:(n-2*periods)])
x$day3temp <- c(rep(NA,3*periods),x$temp[1:(n-3*periods)])
x$day4temp <- c(rep(NA,4*periods),x$temp[1:(n-4*periods)])
x$day5temp <- c(rep(NA,5*periods),x$temp[1:(n-5*periods)])
x$day6temp <- c(rep(NA,6*periods),x$temp[1:(n-6*periods)])

DESCRIPTION format is incompatible with devtools package

When installing the MEFM-package through devtools, I was thrown an error:

Error read.dcf(path) : Found continuation line starting ' The package requi ...' at begin of record.

It seems this error isn't specific to the MEFM-package. See: Issue 1900.

When installing through githubinstall, all runs smoothly:
install.packages("githubinstall")
library(githubinstall)
gh_install_packages("MEFM-package")
library(MEFM)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.