{"id":13775598,"url":"https://github.com/Akai01/caretForecast","last_synced_at":"2025-05-11T08:32:37.751Z","repository":{"id":56934170,"uuid":"297356014","full_name":"Akai01/caretForecast","owner":"Akai01","description":"Conformal Time Series Forecasting Using State of Art Machine Learning Algorithms","archived":false,"fork":false,"pushed_at":"2022-10-24T07:11:56.000Z","size":2092,"stargazers_count":20,"open_issues_count":3,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-14T04:06:12.798Z","etag":null,"topics":["caret","conformal-prediction","data-science","econometrics","forecast","forecasting","forecasting-models","machine-learning","macroeconometrics","microeconometrics","r","time-series","time-series-forcasting","time-series-prediction"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Akai01.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-21T13:57:10.000Z","updated_at":"2024-04-09T01:12:48.000Z","dependencies_parsed_at":"2022-08-21T05:20:38.382Z","dependency_job_id":null,"html_url":"https://github.com/Akai01/caretForecast","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akai01%2FcaretForecast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akai01%2FcaretForecast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akai01%2FcaretForecast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akai01%2FcaretForecast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Akai01","download_url":"https://codeload.github.com/Akai01/caretForecast/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225027463,"owners_count":17409440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["caret","conformal-prediction","data-science","econometrics","forecast","forecasting","forecasting-models","machine-learning","macroeconometrics","microeconometrics","r","time-series","time-series-forcasting","time-series-prediction"],"created_at":"2024-08-03T17:01:42.254Z","updated_at":"2024-11-17T10:31:40.144Z","avatar_url":"https://github.com/Akai01.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# caretForecast\n\n\u003c!-- badges: start --\u003e\n\n\u003c!-- badges: end --\u003e\n\n\ncaretForecast aspires to equip users with the means of using machine learning algorithms for time series data forecasting.\n\n## Installation\n\nThe CRAN version with:\n\n``` r\ninstall.packages(\"caretForecast\")\n\n```\n\n\nThe development version from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"Akai01/caretForecast\")\n```\n## Example\n\nBy using caretForecast, users can train any regression model that is compatible with the caret package. This allows them to use any machine learning model they need in order to solve specific problems, as shown by the examples below.\n\n\n### Load the library\n\n```{r example1}\nlibrary(caretForecast)\n\ndata(retail_wide, package = \"caretForecast\")\n\n```\n\n### Forecasting with glmboost\n```{r, example2}\ni \u003c- 8\n\ndtlist \u003c- caretForecast::split_ts(retail_wide[,i], test_size = 12)\n\ntraining_data \u003c- dtlist$train\n\ntesting_data \u003c- dtlist$test\n\nfit \u003c- ARml(training_data, max_lag = 12, caret_method = \"glmboost\", \n            verbose = FALSE)\n\nforecast(fit, h = length(testing_data), level = c(80,95))-\u003e fc\n\naccuracy(fc, testing_data)\n\n\nautoplot(fc) + \n  autolayer(testing_data, series = \"testing_data\")\n\n```\n\n### Forecasting with cubist regression\n\n```{r, example3}\ni \u003c- 9\n\ndtlist \u003c- caretForecast::split_ts(retail_wide[,i], test_size = 12)\n\ntraining_data \u003c- dtlist$train\n\ntesting_data \u003c- dtlist$test\n\nfit \u003c- ARml(training_data, max_lag = 12, caret_method = \"cubist\", \n            verbose = FALSE)\n\nforecast(fit, h = length(testing_data), level = c(80,95), PI = TRUE)-\u003e fc\n\naccuracy(fc, testing_data)\n\nautoplot(fc) + \n  autolayer(testing_data, series = \"testing_data\")\n\n```\n\n### Forecasting using Support Vector Machines with Linear Kernel\n\n```{r, example4}\n\ni \u003c- 9\n\ndtlist \u003c- caretForecast::split_ts(retail_wide[,i], test_size = 12)\n\ntraining_data \u003c- dtlist$train\n\ntesting_data \u003c- dtlist$test\n\nfit \u003c- ARml(training_data, max_lag = 12, caret_method = \"svmLinear2\", \n            verbose = FALSE, pre_process = c(\"scale\", \"center\"))\n\nforecast(fit, h = length(testing_data), level = c(80,95), PI = TRUE)-\u003e fc\n\naccuracy(fc, testing_data)\n\nautoplot(fc) + \n  autolayer(testing_data, series = \"testing_data\")\n\nget_var_imp(fc)\n\nget_var_imp(fc, plot = F)\n\n```\n\n### Forecasting using Ridge Regression\n\n```{r, example5}\n\ni \u003c- 8\n\ndtlist \u003c- caretForecast::split_ts(retail_wide[,i], test_size = 12)\n\ntraining_data \u003c- dtlist$train\n\ntesting_data \u003c- dtlist$test\n\nfit \u003c- ARml(training_data, max_lag = 12, caret_method = \"ridge\", \n            verbose = FALSE)\n\nforecast(fit, h = length(testing_data), level = c(80,95), PI = TRUE)-\u003e fc\n\naccuracy(fc, testing_data)\n\nautoplot(fc) + \n  autolayer(testing_data, series = \"testing_data\")\n\nget_var_imp(fc)\n\nget_var_imp(fc, plot = F)\n```\n\n## Adding external variables\n\nThe xreg argument can be used for adding promotions, holidays, and other external variables to the model. In the example below, we will add seasonal dummies to the model. We set the 'seasonal = FALSE' to avoid adding the Fourier series to the model together with seasonal dummies.\n\n```{r, example6}\n\nxreg_train \u003c- forecast::seasonaldummy(AirPassengers)\n\nnewxreg \u003c- forecast::seasonaldummy(AirPassengers, h = 21)\n\nfit \u003c- ARml(AirPassengers, max_lag = 4, caret_method = \"cubist\", \n            seasonal = FALSE, xreg = xreg_train, verbose = FALSE)\n\nfc \u003c- forecast(fit, h = 12, level = c(80, 95, 99), xreg = newxreg)\n\nautoplot(fc)\n\nget_var_imp(fc)\n\n```\n\n# Forecasting Hierarchical or grouped time series\n\n\n```{r, example7, warning=FALSE, message=FALSE}\nlibrary(hts)\n\ndata(\"htseg1\", package = \"hts\")\n\nfc \u003c- forecast(htseg1, h = 4, FUN = caretForecast::ARml, \n               caret_method = \"ridge\", verbose = FALSE)\n\nplot(fc)\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAkai01%2FcaretForecast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAkai01%2FcaretForecast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAkai01%2FcaretForecast/lists"}