Last data update: 2014.03.03

R: M3-Competition forecasts of original competition participants
M3ForecastR Documentation

M3-Competition forecasts of original competition participants

Description

The forecasts from all the original participating methods in the M3 forecasting competition.

Usage

data(M3Forecast)

Format

M3Forecast is a list of data.frames. Each list element is the result of one forecasting method. The data.frame then has the following structure: Each row is the forecast of one series. Rows are named accordingly. In total there are 18 columns, i.e., 18 forecasts. If fewer forecasts than 18 exist, the row is filled up with NA values.

Author(s)

Christoph Bergmeir and Rob Hyndman

Source

http://forecasters.org/resources/time-series-data/m3-competition/.

Detailed results from M3 competition at http://www.insead.edu/facultyresearch/research/doc.cfm?did=1094.

References

Makridakis and Hibon (2000) The M3-competition: results, conclusions and implications. International Journal of Forecasting, 16, 451-476.

Examples

M3Forecast[["NAIVE2"]][1,]

## Not run: 
# calculate errors using the accuracy function 
# from the forecast package

errors <- lapply(M3Forecast, function(f) {
      
      res <- NULL
      
      for(x in 1:length(M3)) {
        
        curr_f <- unlist(f[x,])
        
        if(any(!is.na(curr_f))) {
          curr_res <- accuracy(curr_f, M3[[x]]$xx)
        } else {
          # if no results are available create NA results
          curr_res <- accuracy(M3[[x]]$xx, M3[[x]]$xx)
          curr_res <- rep(NA, length(curr_res))
        }
        
        res <- rbind(res, curr_res)
        
      }
      
      rownames(res) <- NULL
      res      
    })

ind_yearly <- which(unlist(lapply(M3, function(x) {x$period == "YEARLY"})))
ind_quarterly <- which(unlist(lapply(M3, function(x) {x$period == "QUARTERLY"})))
ind_monthly <- which(unlist(lapply(M3, function(x) {x$period == "MONTHLY"})))
ind_other <- which(unlist(lapply(M3, function(x) {x$period == "OTHER"})))

yearly_errors <- t(as.data.frame(lapply(errors, function(x) {colMeans(x[ind_yearly,])})))
quarterly_errors <- t(as.data.frame(lapply(errors, function(x) {colMeans(x[ind_quarterly,])})))
monthly_errors <- t(as.data.frame(lapply(errors, function(x) {colMeans(x[ind_monthly,])})))
other_errors <- t(as.data.frame(lapply(errors, function(x) {colMeans(x[ind_other,])})))

yearly_errors
quarterly_errors
monthly_errors
other_errors

## End(Not run)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Mcomp)
Loading required package: tseries
Loading required package: forecast
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: timeDate
This is forecast 7.1 

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Mcomp/M3Forecast.Rd_%03d_medium.png", width=480, height=480)
> ### Name: M3Forecast
> ### Title: M3-Competition forecasts of original competition participants
> ### Aliases: M3Forecast
> ### Keywords: datasets
> 
> ### ** Examples
> 
> M3Forecast[["NAIVE2"]][1,]
           V1      V2      V3      V4      V5      V6 V7 V8 V9 V10 V11 V12 V13
N0001 4936.99 4936.99 4936.99 4936.99 4936.99 4936.99 NA NA NA  NA  NA  NA  NA
      V14 V15 V16 V17 V18
N0001  NA  NA  NA  NA  NA
> 
> ## Not run: 
> ##D # calculate errors using the accuracy function 
> ##D # from the forecast package
> ##D 
> ##D errors <- lapply(M3Forecast, function(f) {
> ##D       
> ##D       res <- NULL
> ##D       
> ##D       for(x in 1:length(M3)) {
> ##D         
> ##D         curr_f <- unlist(f[x,])
> ##D         
> ##D         if(any(!is.na(curr_f))) {
> ##D           curr_res <- accuracy(curr_f, M3[[x]]$xx)
> ##D         } else {
> ##D           # if no results are available create NA results
> ##D           curr_res <- accuracy(M3[[x]]$xx, M3[[x]]$xx)
> ##D           curr_res <- rep(NA, length(curr_res))
> ##D         }
> ##D         
> ##D         res <- rbind(res, curr_res)
> ##D         
> ##D       }
> ##D       
> ##D       rownames(res) <- NULL
> ##D       res      
> ##D     })
> ##D 
> ##D ind_yearly <- which(unlist(lapply(M3, function(x) {x$period == "YEARLY"})))
> ##D ind_quarterly <- which(unlist(lapply(M3, function(x) {x$period == "QUARTERLY"})))
> ##D ind_monthly <- which(unlist(lapply(M3, function(x) {x$period == "MONTHLY"})))
> ##D ind_other <- which(unlist(lapply(M3, function(x) {x$period == "OTHER"})))
> ##D 
> ##D yearly_errors <- t(as.data.frame(lapply(errors, function(x) {colMeans(x[ind_yearly,])})))
> ##D quarterly_errors <- t(as.data.frame(lapply(errors, function(x) {colMeans(x[ind_quarterly,])})))
> ##D monthly_errors <- t(as.data.frame(lapply(errors, function(x) {colMeans(x[ind_monthly,])})))
> ##D other_errors <- t(as.data.frame(lapply(errors, function(x) {colMeans(x[ind_other,])})))
> ##D 
> ##D yearly_errors
> ##D quarterly_errors
> ##D monthly_errors
> ##D other_errors
> ## End(Not run)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>