library(caretForecast)
train_data <- window(AirPassengers, end = c(1959, 12))
test <- window(AirPassengers, start = c(1960, 1))
ARml(train_data, caret_method = "lm", max_lag = 12) -> fit
forecast(fit, h = length(test), level = c(80,95)) -> fc
autoplot(fc)+ autolayer(test)
accuracy(fc, test)
Run the code above in your browser using DataLab