Reputation: 438
I am passing xreg (external regressors/independent variables) below to auto.arima
, and I get the message xreg should be a numeric matrix or a numeric vector
. I checked for class(xreg)
and got "tbl_df" "tbl" "data.frame"
. I am just trying to lag A and B, and so I introduce A_lagged and B_lagged as the lagged versions. After I put them in as columns, I remove A and B.
Can someone tell me what could be wrong? Thank you.
xreg=Model_Dataset %>%
ungroup() %>%
filter(Category==Cat,Date<ForecastDate+weeks(Horizon)) %>%
select(ExtVariables)%>%
mutate('A_lagged',c(249,head(`A`,-1)))%>%
mutate('B_lagged',c(269,head(`B`,-1)))%>%
select(-`A`,-`B`)
Upvotes: 1
Views: 509
Reputation: 887168
It is ,
in 'A_lagged', and 'B_lagged'. It should be replaced with =
library(dplyr)
Model_Dataset %>%
ungroup() %>%
filter(Category==Cat,Date<ForecastDate+weeks(Horizon)) %>%
select(ExtVariables)%>%
mutate('A_lagged' = c(249,head(A,-1)))%>%
mutate('B_lagged'= c(269,head(B,-1)))%>%
select(-A,-B)
Upvotes: 2