How to get forecasts values from a tslm fit model

Hi, I am running a model from multiple explanatory variables, I have a really good initial model.

Multiple R-squared: 0.915, Adjusted R-squared: 0.8645
F-statistic: 18.12 on 19 and 32 DF, p-value: 4.546e-12

      CV           AIC          AICc           BIC         AdjR2 

6.686973e-05 -6.727102e+02 -5.839102e+02 -5.933413e+02 8.644886e-01

My model name is fit.consMR as in chapter 5 of 5.2 Least squares estimation | Forecasting: Principles and Practice (2nd ed), but I am unable to forecast using fcast <- forecast(consMR)

fcast <- forecast(fit.consMR)
Error in forecast.lm(fit.consMR) : Variables not found in newdata
In addition: Warning messages:
1: 'newdata' had 10 rows but variables found have 67 rows
2: 'newdata' had 10 rows but variables found have 67 rows

My time series has 67 rows (1 per month per year, from october 2015 to april 2021), and a column per variable (my dependant variable is on column 1 and the following columns are explanatory ones. I do have some NA on my data.

Thanks for your help!

P.D. I found a thread of a similar scenario Forecasting with xreg=snaive - #8

I was able to follow a solution provided, but I got stuck on forecast,

fc <- forecast(tslm_fit, newdata = BoxCox(test, lambda = "auto"), h = 12)
Error in var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = na.rm) :
is.atomic(x) is not TRUE

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.