Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CV of an hybrid model with xreg. #96

Open
ASLlohmann opened this issue Sep 24, 2020 · 0 comments
Open

CV of an hybrid model with xreg. #96

ASLlohmann opened this issue Sep 24, 2020 · 0 comments

Comments

@ASLlohmann
Copy link
Contributor

ASLlohmann commented Sep 24, 2020

Hi,
I don't know if there is a problem but it seems that the cv function struggle to handle the xreg argument if we choose an hybridModel as FUN

y=ts(rnorm(100), start=c(1999,1), frequency=12)
x=ts(rnorm(100), start=c(1999,1), frequency=12)

When I run this code:

cv.1=forecastHybrid::cvts(y, FUN=hybridModel, models="an",
  rolling = TRUE,
  windowSize = 84 ,a.args=list(xreg=cbind(x)),
  maxHorizon = 1)

I get this error message:

Error during wrapup: task 1 failed - "variable lengths differ (found for 'xregg')"
Error: no more error handlers available (recursive errors?); invoking 'abort' restart

Any idea of the problem ?

Edit : I just found the solution to the problem.

cv = cvts(y, FUN = function(z, xreg = xreg), 
  forecastHybrid::hybridModel(z,models = "an")}, 
  xreg=as.matrix(x),rolling = TRUE,  windowSize = 84, 
  maxHorizon = 1,  horizonAverage = FALSE)

This is quite tricky, probably it could be nice to add an example in the R/Rd files.

#Using custom model functions with xreg.
cvmodCustom=cvts(series, FUN=function(y, xreg=xreg){hybridModel(y,
models="an")}, xreg=x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant