Hi,
I am familiar with the forecast package and am making the transition over to fable and tidyverse.
Example data, at daily frequency, (with more rows) in a rawdata.csv file is as follows:
Index,Var1,Var2,Var3,nIndex,Var_weekday
2022-01-04,5.764,10.0179,0.9133,1,1
2022-01-05,5.7652,10.0185,0.9185,2,2
2022-01-06,5.7637,10.0186,0.9124,3,3
2022-01-07,5.7618,10.0162,0.911,4,4
2022-01-08,5.762,10.0169,0.9154,5,5
2022-01-11,5.765,10.0170,0.9154,6,1
2022-01-13,5.766,10.0173,0.9141,7,3
I am attempting to loop through the columns in a tsibble, and want to estimate 3 separate ARIMA models, each for Var1, Var2, Var3, only, in a for loop, but having difficulties in choosing the column and column name for ARIMA.
#===============================
library(fpp3)
data <- readr::read_csv("path to rawdata.csv")
data_tsibble <-
data %>%
mutate(Index = nIndex) %>%
as_tsibble(index = Index, key = NULL, regular = TRUE)
str(data_tsibble)
x <- colnames(data_tsibble)
for (i in c(x[2],x[3],x[4])) {
refit <-
data_tsibble %>%
model(arima110000 = ARIMA( i ~ 1 + pdq(1,1,0),
method = "CSS-ML",
optim.control = list(maxit=1000))) %>%
select(arima110000) %>%
report()
}
Please can you advise on the above. Thanks.
Amarjit
Referred here by Forecasting: Principles and Practice, by Rob J Hyndman and George Athanasopoulos