[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.
options(repos = c( techtonique = "https://r-packages.techtonique.net", CRAN = "https://cloud.r-project.org" )) install.packages(c("ahead", "misc", "fpp2", "glmnet")) sets <- list(USAccDeaths, AirPassengers, fpp2::a10, fdeaths) # Default: ridge par(mfrow=c(2, 2)) for (x in sets) { xreg <- ahead::createtrendseason(x) train_test_x <- misc::splitts(x, split_prob = 0.8) xreg_training <- window(xreg, start=start(train_test_x$training), end=end(train_test_x$training)) xreg_testing <- window(xreg, start=start(train_test_x$testing), end=end(train_test_x$testing)) h <- length(train_test_x$testing) plot(ahead::dynrmf(y=train_test_x$training, xreg_fit=xreg_training, xreg_predict=xreg_testing, level=99, h=h)) } # Default: glmnet::cv.glmnet par(mfrow=c(2, 2)) for (x in sets) { xreg <- ahead::createtrendseason(x) train_test_x <- misc::splitts(x, split_prob = 0.8) xreg_training <- window(xreg, start=start(train_test_x$training), end=end(train_test_x$training)) xreg_testing <- window(xreg, start=start(train_test_x$testing), end=end(train_test_x$testing)) h <- length(train_test_x$testing) plot(ahead::dynrmf(y=train_test_x$training, xreg_fit=xreg_training, xreg_predict=xreg_testing, fit_func = glmnet::cv.glmnet, level=99, h=h)) }
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.