[This article was first published on T. Moudiki's Webpage - R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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)
To leave a comment for the author, please follow the link and comment on their blog: T. Moudiki's Webpage - R.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
