MmultiplestepAhead: MmultiplestepAhead

View source: R/mstep.R

MmultiplestepAheadR Documentation

MmultiplestepAhead

Description

MmultiplestepAhead: multi-variate multi-step-ahead forecaster

Arguments

TS:

time series [T,m] where m>1 is the number of series

n:

embedding order

dfmlmethods:

alternative methods from MmultiplestepAhead used by DFML to predict factors

H:

horizon

unimethod:

method from MmultiplestepAhead used to predict each univariate series

multi:
  • UNI: prediction based on univariate forecasting with unimethod in MmultiplestepAhead

  • DFM: prediction based on DFM

  • DFML: prediction based on DFML

  • VAR: prediction based on VAR

  • VARs: prediction based on VAR shrink from VARshrink package

  • RNN: prediction based on python (reticulate) implementation of rnn (recurrent neural network)

  • LSTM: prediction based on python (reticulate) implementation of lstm (long short term memory)

  • TRANSF: prediction based on python (reticulate) implementation of a transformer

  • MIMO_rr: prediction based on a MIMO ridge regressor (lambda estimation based on PRESS)

  • MITER_rr: prediction based on an iterated ridge regressor (lambda estimation based on PRESS and a criterion with horizon Hobj)

  • MIMO_red: prediction based on a MIMO reduced rank regressor (rrpack)

  • MIMO_cca: prediction based on a MIMO CCA

  • MIMO_pls: prediction based on a MIMO partial least-squares (Sklearn python)

  • MIMO_las: prediction based on a MIMO lasso (Sklearn python)

  • MIMO_rf: prediction based on a MIMO Random Forest (Sklearn python)

  • MIMO_ml: prediction based on MIMO direct strategy and predictor from pred

  • MIMO_fs: prediction based on MISO direct strategy and feature selection (predictor from pred)

Details

MmultiplestepAhead

Wrapper over a set of methods for multi variate multiple step ahead time series prediction

The python forecasters require the installation of reticulate and several python packages (scikit-learn, tensorflow, keras)

Value

matrix [H,m] with the H step ahead predictions for m series

Author(s)

Gianluca Bontempi Gianluca.Bontempi@ulb.be

References

https://tinyurl.com/sfmlh

Examples

## Multi-variate Multi-step-ahead time series forecasting
rm(list=ls())
library(gbcode)
library(reticulate)
set.seed(0)
N=1000
m=3
n=3 
H=10
TS<-array(0,c(N,m))
for (j in 1:m){
 for (f in 1:5)
   TS[,j]=TS[,j]+sin(2*pi*(1:(N))/runif(1,8,20))
 TS[,j]=TS[,j]+rnorm(N,sd=0.3)

}
TS=scale(TS)
N=NROW(TS)

#P=MmultiplestepAhead(TS[1:(N-H),],n=n,H=H,multi="RNN",
#                    nepochs=100, nunits=10)
P=MmultiplestepAhead(TS[1:(N-H),],n=n,H=H,multi="MITER_rr",
                    nLambdas=150)
if (m==1)
 P=cbind(P)
cat("MSE=",mean((P-TS[(N-H+1):N,])^2),"\n")
par(mfrow=c(1,m))
Nvis=round(N-4*H)
for (j in 1:m){
 Yhat=numeric(N)+NA
 Yhat[(N-H+1):N]=P[,j]
 plot(TS[Nvis:N,j],type="l",
      main=paste("MSE=",round(mean((TS[(N-H+1):N,j]- Yhat[(N-H+1):N])^2),2)))
 lines(Yhat[Nvis:N],col="red",lw=3)
}


gbonte/gbcode documentation built on Feb. 27, 2024, 7:38 a.m.