MmultiplestepAhead | R Documentation |
MmultiplestepAhead: multi-variate multi-step-ahead forecaster
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: |
|
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)
matrix [H,m] with the H step ahead predictions for m series
Gianluca Bontempi Gianluca.Bontempi@ulb.be
## 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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.