ahead::ctxthetaf has no more contextual information about the time series (ahead::contextridge2f still does), but it still works, and can still be used notably with caretS3 (a caret derivative introduced in https://thierrymoudiki.github.io/blog/2026/10/25/r/caretS3-ahead) to forecast time series data. The following code demonstrates how to use caretS3 models for time series forecasting with ahead::ctxthetaf.

list_models <- caret::modelLookup()[caret::modelLookup()[,"forReg"]==TRUE, 1]

n_models <- length(list_models)

pb <- utils::txtProgressBar(min = 0, max = n_models, style = 3)

for (i in seq_len(n_models))
{
  ts_model <- try(ahead::ctxthetaf(y=fdeaths, 
                                   theta = 1,
                                   h=25L, 
                                   fit_func = function (x, y) caretS3::caretS3(x, y, 
                                                                               method=list_models[i])), 
                  silent = TRUE)
  if (class(ts_model) != "try-error")
  {
    plot(ts_model) 
  } 
  utils::setTxtProgressBar(pb, i)
}

close(pb)

Comments powered by Talkyard.