Package 'Mcomp'

Title: Data from the M-Competitions
Description: The 1001 time series from the M-competition (Makridakis et al. 1982) <DOI:10.1002/for.3980010202> and the 3003 time series from the IJF-M3 competition (Makridakis and Hibon, 2000) <DOI:10.1016/S0169-2070(00)00057-1>.
Authors: Rob Hyndman [aut, cre, cph] , Muhammad Akram [ctb], Christoph Bergmeir [ctb] , Mitchell O'Hara-Wild [ctb], Yangzhuoran Fin Yang [ctb]
Maintainer: Rob Hyndman <[email protected]>
License: GPL-3
Version: 2.9
Built: 2024-12-28 06:46:06 UTC
Source: https://github.com/robjhyndman/Mcomp

Help Index


Data from the M-competitions

Description

The 1001 time series from the M-competition (Makridakis et al. 1982), and the 3003 time series and forecasts from the IJF-M3 competition (Makridakis and Hibon, 2000).

Author(s)

Rob J Hyndman. [email protected], with assistance from Muhammad Akram and Christoph Bergmeir.

Source

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

References

Makridakis, S., A. Andersen, R. Carbone, R. Fildes, M. Hibon, R. Lewandowski, J. Newton, E. Parzen, and R. Winkler (1982) The accuracy of extrapolation (time series) methods: results of a forecasting competition. Journal of Forecasting, 1, 111–153.

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


M-Competition data

Description

The time series from the M1 forecasting competition.

Usage

M1

Format

M1 is a list of 1001 series of class Mcomp. Each series within M1 is of class Mdata with the following structure:

sn

Name of the series

st

Series number and period. For example "Y1" denotes first yearly series, "Q20" denotes 20th quarterly series and so on.

n

The number of observations in the time series

h

The number of required forecasts

period

Interval of the time series. Possible values are "YEARLY", "QUARTERLY", "MONTHLY" & "OTHER".

type

The type of series. Possible values are "DEMOGR", "INDUST", "MACRO1", "MACRO2", "MICRO1", "MICRO2" & "MICRO3".

description

A short description of the time series

x

A time series of length n (the historical data)

xx

A time series of length h (the future data)

Author(s)

Muhammad Akram and Rob Hyndman

Source

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

References

Makridakis, S., A. Andersen, R. Carbone, R. Fildes, M. Hibon, R. Lewandowski, J. Newton, E. Parzen, and R. Winkler (1982) The accuracy of extrapolation (time series) methods: results of a forecasting competition. Journal of Forecasting, 1, 111–153.

See Also

M3, subset.Mcomp, plot.Mdata

Examples

M1
plot(M1$YAF2)
subset(M1,"monthly")

M3-Competition data

Description

The time series from the M3 forecasting competition.

Usage

M3

Format

M3 is a list of 3003 series of class Mcomp. Each series within M3 is of class Mdata with the following structure:

sn

Name of the series

st

Series number and period. For example "Y1" denotes first yearly series, "Q20" denotes 20th quarterly series and so on.

n

The number of observations in the time series

h

The number of required forecasts

period

Interval of the time series. Possible values are "YEARLY", "QUARTERLY", "MONTHLY" & "OTHER".

type

The type of series. Possible values for M3 are "DEMOGRAPHIC", "FINANCE", "INDUSTRY", "MACRO", "MICRO", "OTHER".

description

A short description of the time series

x

A time series of length n (the historical data)

xx

A time series of length h (the future data)

Author(s)

Muhammad Akram and Rob Hyndman

Source

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

References

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

See Also

subset.Mcomp, plot.Mdata

Examples

M3
plot(M3[[32]])
subset(M3,"monthly")

M3-Competition forecasts of original competition participants

Description

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

Usage

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/.

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)

Plotting M Competition data

Description

Functions to plot a time series from the M competition data sets, showing both the training and test sections of the series.

Usage

## S3 method for class 'Mdata'
plot(x, xlim = c(tsp(x$x)[1], tsp(x$xx)[2]),
  ylim = range(x$x, x$xx), main = x$sn, xlab, ylab = "", ...)

## S3 method for class 'Mdata'
autoplot(object, ...)

Arguments

x, object

A series of M-competition data

xlim

Limits on x-axis

ylim

Limits on y-axis

main

Main title

xlab

Label on x-axis

ylab

Label on y-axis

...

Other plotting arguments passed to plot. Ignored for autoplot.

Value

autoplot.Mdata returns a ggplot2 object, while plot.Mdata returns nothing. Both functions produce a time series plot of the selected series.

Author(s)

Rob Hyndman

See Also

M1, M3

Examples

library(ggplot2)
plot(M1[[1]])
autoplot(M1$YAF3)
autoplot(M3[["N0647"]])

Subset of time series from the M Competitions

Description

subset.Mcomp returns a subset of the time series data from the M Competitions. Subsets can be for specific periods, or specific types of data or both.

Usage

## S3 method for class 'Mcomp'
subset(x, cond1, cond2, ...)

Arguments

x

M-competition data or a subset of M-competition data

cond1

Type or period of the data. Type is a character variable and period could be character or numeric.

cond2

Optional second condition specifying type or period of the data, depending on cond1. If cond1 denotes type then cond2 would denote period, but if cond1 denotes period then cond2 would denote type.

...

Other arguments.

Details

Possible values for cond1 and cond2 denoting period are 1, 4, 12, "yearly", "quarterly", "monthly" and "other".

If cond1 or cond2 equals 111, then the 111 series used in the extended comparisons in the 1982 M-competition are selected.

Possible values for cond1 and cond2 denoting type are "macro", "micro", "industry", "finance", "demographic", "allother", "macro1", "macro2", "micro1", "micro2", "micro3". These correspond to the descriptions used in the competitions. See the references for details.

Partial matching used for both conditions.

Value

An object of class Mcomp consisting of the selected series.

Author(s)

Muhammad Akram and Rob Hyndman

References

Makridakis, S., A. Andersen, R. Carbone, R. Fildes, M. Hibon, R. Lewandowski, J. Newton, E. Parzen, and R. Winkler (1982) The accuracy of extrapolation (time series) methods: results of a forecasting competition. Journal of Forecasting, 1, 111–153.

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

See Also

M1

Examples

M3.quarterly <- subset(M3,4)
M1.yearly.industry <- subset(M1,1,"industry")