GeoBosh / sarima

Time series modelling with extended regression SARIMA models
https://geobosh.github.io/sarima/
3 stars 3 forks source link

i(n) terms fail when using exogenous regressors #2

Open samkodes opened 4 months ago

samkodes commented 4 months ago

When trying to use an exogenous regressor with an i(n) (e.g. i(1)) term, the sarima function throws an error. For example:

testdata <- data.frame(y1=rnorm(100),x1 = rnorm(100))

smod2 <- sarima( y1 ~   x1 | ar(1)+i(1),
                 data=testdata
                 )

The error is: Error in model.frame.default(formula, data = data.frame(.dummy = t), na.action = NULL) : variable lengths differ (found for 'x1')

I am guessing this has to do with differencing the exogenous regressor, but this seems like a very common use case?

Would the solution simply be to pre-difference the data so the i(1) term is not required, though this demands that the user re-integrate any forecast?

GeoBosh commented 4 months ago

Thanks for the report and the complete example.

This looks like a bug, I will check.