0

I have a function which takes a fitted model and then refits that model to new training data (this is for step-ahead cross validation). For lm models it works like this:

#create data
training_data <-
    data.frame(date = seq.Date(
        from = as.Date("2020-01-01"),
        by = 1, length.out = 365
    ), x = 1:365, y = 1:365 + rnorm(n = 365))

# specify and fit model
lm_formula <- as.formula(y ~ x)
my_lm <- lm(lm_formula, data = training_data)

# refit on new training data
update(my_lm, data = new_training_data)

Is there a way to do the same thing for arima models fitted with the fable package? I'm creating the models like this

library(fable)
library(forecast)
arima_formula <- as.formula(y ~ x + PDQ(0, 0, 0))
my_arima <- as_tsibble(training_data) %>% model(ARIMA(arima_formula))

But I can't figure out a way to take the my_arima model that I've already fitted and pass it new_training_data, either using update or by extracting the formula and refitting as a new model. Note that although I've included the model formula in the reprex above, my function takes a fitted model rather than a formula. So just fitting a new model using arima_formula is not an option.

Thank you.

jay
  • 517
  • 1
  • 7
  • 19

0 Answers0