MatthieuStigler / tsDyn

tsDyn
tsdyn.googlecode.com
GNU General Public License v2.0
34 stars 20 forks source link

predict_rolling does not handle exogenous variables #18

Open MatthieuStigler opened 4 years ago

MatthieuStigler commented 4 years ago

predict_rolling does not work with exogenous variables: this is because predict_rolling_1step.nlVar only retrieves the endogenous ones: origSerie <- object$model[,1:k].

Now this will be complicated:

  1. Need to extract position of exo in object$model[,1:k], no easy way so far
  2. object$model returns exo with NAs (check: head(VECM_Exo$model))... maybe problem
  3. exos need to be fed also as exoPred in predict.nlar...
library(tsDyn)
#> Registered S3 method overwritten by 'quantmod':
#>   method            from
#>   as.zoo.data.frame zoo
data("barry")
barry_pre <- barry[1:300,]
barry_post <- barry[301:324,]

VECM_noExo <- tsDyn::VECM(barry_pre[,1:2],2, r=1,c("none"), beta=NULL,estim = "ML", c("none"))
ok <- predict_rolling(VECM_noExo,nroll= 18, refit.every = 0, n.ahead = 18, newdata=barry_post[,1:2] )

VECM_Exo <- tsDyn::VECM(barry_pre[,1:2],2, r=1,c("none"), beta=NULL,estim = "ML", c("none"), barry_pre[,3])
predict_rolling(VECM_Exo, nroll= 18, refit.every = 0, n.ahead = 18, newdata=barry_post)
#> Error in rbind(origSerie, newdata): number of columns of matrices must match (see arg 2)

Created on 2020-05-14 by the reprex package (v0.3.0)