From 797aadfa3262b9b78e77ad27b4570c6479161dd3 Mon Sep 17 00:00:00 2001 From: MMenchero Date: Tue, 28 May 2024 20:40:35 -0600 Subject: [PATCH] Added vignette on exogenous variables. --- README.Rmd | 5 +- _pkgdown.yml | 2 + .../forecast_multi_series-9d2e84-POST.json | 622 +++++++++++++++++ .../forecast_multi_series-c8b6a1-POST.json | 633 ++++++++++++++++++ .../forecast_multi_series-9d2e84-POST.json | 622 +++++++++++++++++ .../forecast_multi_series-c8b6a1-POST.json | 633 ++++++++++++++++++ vignettes/exogenous-variables.Rmd | 81 +++ 7 files changed, 2596 insertions(+), 2 deletions(-) create mode 100644 tests/mocks/dashboard.nixtla.io/api/forecast_multi_series-9d2e84-POST.json create mode 100644 tests/mocks/dashboard.nixtla.io/api/forecast_multi_series-c8b6a1-POST.json create mode 100644 tests/testthat/dashboard.nixtla.io/api/forecast_multi_series-9d2e84-POST.json create mode 100644 tests/testthat/dashboard.nixtla.io/api/forecast_multi_series-c8b6a1-POST.json create mode 100644 vignettes/exogenous-variables.Rmd diff --git a/README.Rmd b/README.Rmd index 0e68434..259c226 100644 --- a/README.Rmd +++ b/README.Rmd @@ -108,7 +108,7 @@ nixtlar::nixtla_client_plot(df, nixtla_client_anomalies, id_col = "unique_id", p # Features and Capabilities -`nixtlar` provides access to all of TimeGPT's features and capabilities, such as: +`nixtlar` provides access to TimeGPT's features and capabilities, such as: - **Zero-shot Inference**: TimeGPT can generate forecasts and detect anomalies straight out of the box, requiring no prior training data. This allows for immediate deployment and quick insights from any time series data. @@ -132,8 +132,9 @@ For comprehensive documentation, please refer to our vignettes, which cover a wi - [Get started and set up your API key](https://nixtla.github.io/nixtlar/articles/get-started.html) - [Do anomaly detection](https://nixtla.github.io/nixtlar/articles/anomaly-detection.html) -- [Generate historical forecasts](https://nixtla.github.io/nixtlar/articles/historical-forecast.html) - [Perform time series cross-validation](https://nixtla.github.io/nixtlar/articles/cross-validation.html) +- [Use exogenous variables](https://nixtla.github.io/nixtlar/articles/exogenous-variables.html) +- [Generate historical forecasts](https://nixtla.github.io/nixtlar/articles/historical-forecast.html) The documentation is an ongoing effort, and we are working on expanding its coverage. diff --git a/_pkgdown.yml b/_pkgdown.yml index 2855009..30fd260 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -19,6 +19,8 @@ navbar: - href: articles/anomaly-detection.html - text: "Cross-Validation" - href: articles/cross-validation.html + - text: "Exogenous Variables" + - href: articles/exogenous-variables.html - text: "Historical Forecast" - href: articles/historical-forecast.html right: diff --git a/tests/mocks/dashboard.nixtla.io/api/forecast_multi_series-9d2e84-POST.json b/tests/mocks/dashboard.nixtla.io/api/forecast_multi_series-9d2e84-POST.json new file mode 100644 index 0000000..a45cdc4 --- /dev/null +++ b/tests/mocks/dashboard.nixtla.io/api/forecast_multi_series-9d2e84-POST.json @@ -0,0 +1,622 @@ +{ + "status": 200, + "data": { + "forecast": { + "columns": [ + "unique_id", + "ds", + "TimeGPT" + ], + "data": [ + [ + "BE", + "2016-12-31 00:00:00", + 45.190452575683594 + ], + [ + "BE", + "2016-12-31 01:00:00", + 43.24444580078125 + ], + [ + "BE", + "2016-12-31 02:00:00", + 41.95838928222656 + ], + [ + "BE", + "2016-12-31 03:00:00", + 39.796485900878906 + ], + [ + "BE", + "2016-12-31 04:00:00", + 39.204532623291016 + ], + [ + "BE", + "2016-12-31 05:00:00", + 40.10877990722656 + ], + [ + "BE", + "2016-12-31 06:00:00", + 43.34886932373047 + ], + [ + "BE", + "2016-12-31 07:00:00", + 48.455711364746094 + ], + [ + "BE", + "2016-12-31 08:00:00", + 54.38892364501953 + ], + [ + "BE", + "2016-12-31 09:00:00", + 55.92976379394531 + ], + [ + "BE", + "2016-12-31 10:00:00", + 55.57164764404297 + ], + [ + "BE", + "2016-12-31 11:00:00", + 54.2220458984375 + ], + [ + "BE", + "2016-12-31 12:00:00", + 52.68199157714844 + ], + [ + "BE", + "2016-12-31 13:00:00", + 51.62413024902344 + ], + [ + "BE", + "2016-12-31 14:00:00", + 51.51112365722656 + ], + [ + "BE", + "2016-12-31 15:00:00", + 54.010162353515625 + ], + [ + "BE", + "2016-12-31 16:00:00", + 57.16205596923828 + ], + [ + "BE", + "2016-12-31 17:00:00", + 61.22026062011719 + ], + [ + "BE", + "2016-12-31 18:00:00", + 62.06513977050781 + ], + [ + "BE", + "2016-12-31 19:00:00", + 59.04737854003906 + ], + [ + "BE", + "2016-12-31 20:00:00", + 55.35999298095703 + ], + [ + "BE", + "2016-12-31 21:00:00", + 51.852272033691406 + ], + [ + "BE", + "2016-12-31 22:00:00", + 50.590476989746094 + ], + [ + "BE", + "2016-12-31 23:00:00", + 48.92185974121094 + ], + [ + "DE", + "2017-12-31 00:00:00", + -0.24724960327148438 + ], + [ + "DE", + "2017-12-31 01:00:00", + -1.9071083068847656 + ], + [ + "DE", + "2017-12-31 02:00:00", + -3.1054420471191406 + ], + [ + "DE", + "2017-12-31 03:00:00", + -3.2229766845703125 + ], + [ + "DE", + "2017-12-31 04:00:00", + -3.3456268310546875 + ], + [ + "DE", + "2017-12-31 05:00:00", + -2.3639450073242188 + ], + [ + "DE", + "2017-12-31 06:00:00", + -1.7124366760253906 + ], + [ + "DE", + "2017-12-31 07:00:00", + -0.9053115844726562 + ], + [ + "DE", + "2017-12-31 08:00:00", + 0.5612297058105469 + ], + [ + "DE", + "2017-12-31 09:00:00", + 1.9465141296386719 + ], + [ + "DE", + "2017-12-31 10:00:00", + 2.397075653076172 + ], + [ + "DE", + "2017-12-31 11:00:00", + 2.942707061767578 + ], + [ + "DE", + "2017-12-31 12:00:00", + 3.21575927734375 + ], + [ + "DE", + "2017-12-31 13:00:00", + 3.3599586486816406 + ], + [ + "DE", + "2017-12-31 14:00:00", + 3.9961013793945312 + ], + [ + "DE", + "2017-12-31 15:00:00", + 4.823101043701172 + ], + [ + "DE", + "2017-12-31 16:00:00", + 4.9681243896484375 + ], + [ + "DE", + "2017-12-31 17:00:00", + 5.674430847167969 + ], + [ + "DE", + "2017-12-31 18:00:00", + 6.163536071777344 + ], + [ + "DE", + "2017-12-31 19:00:00", + 5.7597198486328125 + ], + [ + "DE", + "2017-12-31 20:00:00", + 4.083599090576172 + ], + [ + "DE", + "2017-12-31 21:00:00", + 2.9927520751953125 + ], + [ + "DE", + "2017-12-31 22:00:00", + 1.9278450012207031 + ], + [ + "DE", + "2017-12-31 23:00:00", + -0.0162811279296875 + ], + [ + "FR", + "2016-12-31 00:00:00", + 63.240081787109375 + ], + [ + "FR", + "2016-12-31 01:00:00", + 59.24473571777344 + ], + [ + "FR", + "2016-12-31 02:00:00", + 55.723838806152344 + ], + [ + "FR", + "2016-12-31 03:00:00", + 52.209632873535156 + ], + [ + "FR", + "2016-12-31 04:00:00", + 51.02058410644531 + ], + [ + "FR", + "2016-12-31 05:00:00", + 53.5487060546875 + ], + [ + "FR", + "2016-12-31 06:00:00", + 58.21989440917969 + ], + [ + "FR", + "2016-12-31 07:00:00", + 64.41748809814453 + ], + [ + "FR", + "2016-12-31 08:00:00", + 68.54605102539062 + ], + [ + "FR", + "2016-12-31 09:00:00", + 69.43729400634766 + ], + [ + "FR", + "2016-12-31 10:00:00", + 68.75494384765625 + ], + [ + "FR", + "2016-12-31 11:00:00", + 67.91847229003906 + ], + [ + "FR", + "2016-12-31 12:00:00", + 66.1435317993164 + ], + [ + "FR", + "2016-12-31 13:00:00", + 62.43498229980469 + ], + [ + "FR", + "2016-12-31 14:00:00", + 59.81889343261719 + ], + [ + "FR", + "2016-12-31 15:00:00", + 61.035003662109375 + ], + [ + "FR", + "2016-12-31 16:00:00", + 63.111297607421875 + ], + [ + "FR", + "2016-12-31 17:00:00", + 70.69346618652344 + ], + [ + "FR", + "2016-12-31 18:00:00", + 73.90049743652344 + ], + [ + "FR", + "2016-12-31 19:00:00", + 73.69876861572266 + ], + [ + "FR", + "2016-12-31 20:00:00", + 71.09501647949219 + ], + [ + "FR", + "2016-12-31 21:00:00", + 67.445556640625 + ], + [ + "FR", + "2016-12-31 22:00:00", + 65.951904296875 + ], + [ + "FR", + "2016-12-31 23:00:00", + 62.771888732910156 + ], + [ + "NP", + "2018-12-24 00:00:00", + 51.033172607421875 + ], + [ + "NP", + "2018-12-24 01:00:00", + 50.12208938598633 + ], + [ + "NP", + "2018-12-24 02:00:00", + 49.71585464477539 + ], + [ + "NP", + "2018-12-24 03:00:00", + 49.13131332397461 + ], + [ + "NP", + "2018-12-24 04:00:00", + 49.641170501708984 + ], + [ + "NP", + "2018-12-24 05:00:00", + 51.29006576538086 + ], + [ + "NP", + "2018-12-24 06:00:00", + 53.28921890258789 + ], + [ + "NP", + "2018-12-24 07:00:00", + 55.38706588745117 + ], + [ + "NP", + "2018-12-24 08:00:00", + 56.115516662597656 + ], + [ + "NP", + "2018-12-24 09:00:00", + 56.09071350097656 + ], + [ + "NP", + "2018-12-24 10:00:00", + 55.813716888427734 + ], + [ + "NP", + "2018-12-24 11:00:00", + 55.52851867675781 + ], + [ + "NP", + "2018-12-24 12:00:00", + 55.7847900390625 + ], + [ + "NP", + "2018-12-24 13:00:00", + 55.709617614746094 + ], + [ + "NP", + "2018-12-24 14:00:00", + 55.3892707824707 + ], + [ + "NP", + "2018-12-24 15:00:00", + 56.03938674926758 + ], + [ + "NP", + "2018-12-24 16:00:00", + 57.58835220336914 + ], + [ + "NP", + "2018-12-24 17:00:00", + 59.171669006347656 + ], + [ + "NP", + "2018-12-24 18:00:00", + 58.9607048034668 + ], + [ + "NP", + "2018-12-24 19:00:00", + 56.43702697753906 + ], + [ + "NP", + "2018-12-24 20:00:00", + 54.62592697143555 + ], + [ + "NP", + "2018-12-24 21:00:00", + 53.492652893066406 + ], + [ + "NP", + "2018-12-24 22:00:00", + 52.30442428588867 + ], + [ + "NP", + "2018-12-24 23:00:00", + 50.93275451660156 + ], + [ + "PJM", + "2018-12-24 00:00:00", + 21.008119583129883 + ], + [ + "PJM", + "2018-12-24 01:00:00", + 20.60911750793457 + ], + [ + "PJM", + "2018-12-24 02:00:00", + 20.260807037353516 + ], + [ + "PJM", + "2018-12-24 03:00:00", + 20.296545028686523 + ], + [ + "PJM", + "2018-12-24 04:00:00", + 21.065902709960938 + ], + [ + "PJM", + "2018-12-24 05:00:00", + 20.480093002319336 + ], + [ + "PJM", + "2018-12-24 06:00:00", + 23.40868377685547 + ], + [ + "PJM", + "2018-12-24 07:00:00", + 27.09423828125 + ], + [ + "PJM", + "2018-12-24 08:00:00", + 28.25070571899414 + ], + [ + "PJM", + "2018-12-24 09:00:00", + 28.379547119140625 + ], + [ + "PJM", + "2018-12-24 10:00:00", + 27.78171730041504 + ], + [ + "PJM", + "2018-12-24 11:00:00", + 26.666141510009766 + ], + [ + "PJM", + "2018-12-24 12:00:00", + 25.683338165283203 + ], + [ + "PJM", + "2018-12-24 13:00:00", + 24.544357299804688 + ], + [ + "PJM", + "2018-12-24 14:00:00", + 24.27858543395996 + ], + [ + "PJM", + "2018-12-24 15:00:00", + 24.576183319091797 + ], + [ + "PJM", + "2018-12-24 16:00:00", + 26.073471069335938 + ], + [ + "PJM", + "2018-12-24 17:00:00", + 32.80261993408203 + ], + [ + "PJM", + "2018-12-24 18:00:00", + 33.22092819213867 + ], + [ + "PJM", + "2018-12-24 19:00:00", + 32.02828598022461 + ], + [ + "PJM", + "2018-12-24 20:00:00", + 30.907085418701172 + ], + [ + "PJM", + "2018-12-24 21:00:00", + 28.066879272460938 + ], + [ + "PJM", + "2018-12-24 22:00:00", + 25.063722610473633 + ], + [ + "PJM", + "2018-12-24 23:00:00", + 23.301254272460938 + ] + ] + }, + "input_tokens": 8400, + "output_tokens": 120, + "finetune_tokens": 0 + }, + "message": "success", + "details": "request successful", + "code": "B10", + "support": "If you have questions or need support, please email ops@nixtla.io sharing this response and ID: 2BLK8REUXE", + "requestID": "2BLK8REUXE" +} diff --git a/tests/mocks/dashboard.nixtla.io/api/forecast_multi_series-c8b6a1-POST.json b/tests/mocks/dashboard.nixtla.io/api/forecast_multi_series-c8b6a1-POST.json new file mode 100644 index 0000000..13522c6 --- /dev/null +++ b/tests/mocks/dashboard.nixtla.io/api/forecast_multi_series-c8b6a1-POST.json @@ -0,0 +1,633 @@ +{ + "status": 200, + "data": { + "forecast": { + "columns": [ + "unique_id", + "ds", + "TimeGPT" + ], + "data": [ + [ + "BE", + "2016-12-31 00:00:00", + 74.54077259602315 + ], + [ + "BE", + "2016-12-31 01:00:00", + 43.344289274267666 + ], + [ + "BE", + "2016-12-31 02:00:00", + 44.42922020357467 + ], + [ + "BE", + "2016-12-31 03:00:00", + 38.09439509672264 + ], + [ + "BE", + "2016-12-31 04:00:00", + 37.38914113497819 + ], + [ + "BE", + "2016-12-31 05:00:00", + 39.08574109530534 + ], + [ + "BE", + "2016-12-31 06:00:00", + 42.945286252144726 + ], + [ + "BE", + "2016-12-31 07:00:00", + 41.294235898095195 + ], + [ + "BE", + "2016-12-31 08:00:00", + 48.35958324598505 + ], + [ + "BE", + "2016-12-31 09:00:00", + 56.101556413548934 + ], + [ + "BE", + "2016-12-31 10:00:00", + 55.16523822416974 + ], + [ + "BE", + "2016-12-31 11:00:00", + 54.15711101050361 + ], + [ + "BE", + "2016-12-31 12:00:00", + 53.5014752650505 + ], + [ + "BE", + "2016-12-31 13:00:00", + 94.65871557140909 + ], + [ + "BE", + "2016-12-31 14:00:00", + 47.1258567010379 + ], + [ + "BE", + "2016-12-31 15:00:00", + 44.466736114558664 + ], + [ + "BE", + "2016-12-31 16:00:00", + 46.618250561791484 + ], + [ + "BE", + "2016-12-31 17:00:00", + 55.05334153324033 + ], + [ + "BE", + "2016-12-31 18:00:00", + 50.16926113334454 + ], + [ + "BE", + "2016-12-31 19:00:00", + 46.70009368853968 + ], + [ + "BE", + "2016-12-31 20:00:00", + 46.40987888541974 + ], + [ + "BE", + "2016-12-31 21:00:00", + 44.29971977186849 + ], + [ + "BE", + "2016-12-31 22:00:00", + 47.665925812327 + ], + [ + "BE", + "2016-12-31 23:00:00", + 40.72145333467065 + ], + [ + "DE", + "2017-12-31 00:00:00", + -31.295775916483365 + ], + [ + "DE", + "2017-12-31 01:00:00", + -22.184954600736795 + ], + [ + "DE", + "2017-12-31 02:00:00", + -9.493253899038336 + ], + [ + "DE", + "2017-12-31 03:00:00", + -8.152627362314327 + ], + [ + "DE", + "2017-12-31 04:00:00", + -4.975538910071201 + ], + [ + "DE", + "2017-12-31 05:00:00", + -4.709152877966709 + ], + [ + "DE", + "2017-12-31 06:00:00", + -5.6067361755738645 + ], + [ + "DE", + "2017-12-31 07:00:00", + -7.4550841864215585 + ], + [ + "DE", + "2017-12-31 08:00:00", + -8.12062282604029 + ], + [ + "DE", + "2017-12-31 09:00:00", + -19.75437636892527 + ], + [ + "DE", + "2017-12-31 10:00:00", + -20.333697276518045 + ], + [ + "DE", + "2017-12-31 11:00:00", + -35.70595111981811 + ], + [ + "DE", + "2017-12-31 12:00:00", + -66.51799568941819 + ], + [ + "DE", + "2017-12-31 13:00:00", + -72.25607036951848 + ], + [ + "DE", + "2017-12-31 14:00:00", + -71.92610287073919 + ], + [ + "DE", + "2017-12-31 15:00:00", + -71.15767597559758 + ], + [ + "DE", + "2017-12-31 16:00:00", + -36.03780221623819 + ], + [ + "DE", + "2017-12-31 17:00:00", + -25.11167902495744 + ], + [ + "DE", + "2017-12-31 18:00:00", + -5.178491903650908 + ], + [ + "DE", + "2017-12-31 19:00:00", + -8.93198933562109 + ], + [ + "DE", + "2017-12-31 20:00:00", + -14.151304138735668 + ], + [ + "DE", + "2017-12-31 21:00:00", + -19.97155089895457 + ], + [ + "DE", + "2017-12-31 22:00:00", + -20.92338843862742 + ], + [ + "DE", + "2017-12-31 23:00:00", + -22.213898616239725 + ], + [ + "FR", + "2016-12-31 00:00:00", + 93.69808083994201 + ], + [ + "FR", + "2016-12-31 01:00:00", + 59.289256278725105 + ], + [ + "FR", + "2016-12-31 02:00:00", + 58.40772066815361 + ], + [ + "FR", + "2016-12-31 03:00:00", + 51.42690810341025 + ], + [ + "FR", + "2016-12-31 04:00:00", + 49.8274405190643 + ], + [ + "FR", + "2016-12-31 05:00:00", + 52.208793897360195 + ], + [ + "FR", + "2016-12-31 06:00:00", + 57.295197692543304 + ], + [ + "FR", + "2016-12-31 07:00:00", + 56.09739335775504 + ], + [ + "FR", + "2016-12-31 08:00:00", + 61.79573089007817 + ], + [ + "FR", + "2016-12-31 09:00:00", + 69.20394522584874 + ], + [ + "FR", + "2016-12-31 10:00:00", + 68.16339282861611 + ], + [ + "FR", + "2016-12-31 11:00:00", + 66.10206770682936 + ], + [ + "FR", + "2016-12-31 12:00:00", + 65.54767491857623 + ], + [ + "FR", + "2016-12-31 13:00:00", + 106.54351948216139 + ], + [ + "FR", + "2016-12-31 14:00:00", + 55.04072555495253 + ], + [ + "FR", + "2016-12-31 15:00:00", + 51.2055969348997 + ], + [ + "FR", + "2016-12-31 16:00:00", + 53.002243363858554 + ], + [ + "FR", + "2016-12-31 17:00:00", + 63.11358898065425 + ], + [ + "FR", + "2016-12-31 18:00:00", + 59.94209735882046 + ], + [ + "FR", + "2016-12-31 19:00:00", + 57.71339093388798 + ], + [ + "FR", + "2016-12-31 20:00:00", + 58.993652992365384 + ], + [ + "FR", + "2016-12-31 21:00:00", + 57.96052269453732 + ], + [ + "FR", + "2016-12-31 22:00:00", + 60.98328491367249 + ], + [ + "FR", + "2016-12-31 23:00:00", + 51.95414278412694 + ], + [ + "NP", + "2018-12-24 00:00:00", + 50.998705925260616 + ], + [ + "NP", + "2018-12-24 01:00:00", + 49.753014352557294 + ], + [ + "NP", + "2018-12-24 02:00:00", + 49.766680505511395 + ], + [ + "NP", + "2018-12-24 03:00:00", + 49.692939546343915 + ], + [ + "NP", + "2018-12-24 04:00:00", + 49.67919805311882 + ], + [ + "NP", + "2018-12-24 05:00:00", + 50.992008270536495 + ], + [ + "NP", + "2018-12-24 06:00:00", + 51.547055035224986 + ], + [ + "NP", + "2018-12-24 07:00:00", + 53.757655142776066 + ], + [ + "NP", + "2018-12-24 08:00:00", + 54.96587353829956 + ], + [ + "NP", + "2018-12-24 09:00:00", + 58.18303841834125 + ], + [ + "NP", + "2018-12-24 10:00:00", + 59.30602568676899 + ], + [ + "NP", + "2018-12-24 11:00:00", + 58.34717282336318 + ], + [ + "NP", + "2018-12-24 12:00:00", + 55.4861651439583 + ], + [ + "NP", + "2018-12-24 13:00:00", + 55.355408765784475 + ], + [ + "NP", + "2018-12-24 14:00:00", + 55.270492650977346 + ], + [ + "NP", + "2018-12-24 15:00:00", + 55.11098776053545 + ], + [ + "NP", + "2018-12-24 16:00:00", + 52.87967378114751 + ], + [ + "NP", + "2018-12-24 17:00:00", + 52.08690451778381 + ], + [ + "NP", + "2018-12-24 18:00:00", + 50.99290766299118 + ], + [ + "NP", + "2018-12-24 19:00:00", + 49.24441132198188 + ], + [ + "NP", + "2018-12-24 20:00:00", + 49.429914327963324 + ], + [ + "NP", + "2018-12-24 21:00:00", + 48.137836361407906 + ], + [ + "NP", + "2018-12-24 22:00:00", + 47.208843554937886 + ], + [ + "NP", + "2018-12-24 23:00:00", + 47.12802156397109 + ], + [ + "PJM", + "2018-12-24 00:00:00", + 23.075717332376897 + ], + [ + "PJM", + "2018-12-24 01:00:00", + 22.27713547855734 + ], + [ + "PJM", + "2018-12-24 02:00:00", + 22.577886990415728 + ], + [ + "PJM", + "2018-12-24 03:00:00", + 23.459224156248247 + ], + [ + "PJM", + "2018-12-24 04:00:00", + 24.618181637632524 + ], + [ + "PJM", + "2018-12-24 05:00:00", + 22.98238222967354 + ], + [ + "PJM", + "2018-12-24 06:00:00", + 22.6213325789221 + ], + [ + "PJM", + "2018-12-24 07:00:00", + 22.18442771085489 + ], + [ + "PJM", + "2018-12-24 08:00:00", + 28.43632728732061 + ], + [ + "PJM", + "2018-12-24 09:00:00", + 32.10124833017661 + ], + [ + "PJM", + "2018-12-24 10:00:00", + 31.658370789722078 + ], + [ + "PJM", + "2018-12-24 11:00:00", + 31.122157842265203 + ], + [ + "PJM", + "2018-12-24 12:00:00", + 30.65040949021442 + ], + [ + "PJM", + "2018-12-24 13:00:00", + 29.98697310371744 + ], + [ + "PJM", + "2018-12-24 14:00:00", + 29.657021340564363 + ], + [ + "PJM", + "2018-12-24 15:00:00", + 29.204463776782625 + ], + [ + "PJM", + "2018-12-24 16:00:00", + 29.418534573749177 + ], + [ + "PJM", + "2018-12-24 17:00:00", + 35.63065592475516 + ], + [ + "PJM", + "2018-12-24 18:00:00", + 31.75408989012567 + ], + [ + "PJM", + "2018-12-24 19:00:00", + 34.6047677134302 + ], + [ + "PJM", + "2018-12-24 20:00:00", + 35.13864855870446 + ], + [ + "PJM", + "2018-12-24 21:00:00", + 32.8505998145028 + ], + [ + "PJM", + "2018-12-24 22:00:00", + 31.512607142476064 + ], + [ + "PJM", + "2018-12-24 23:00:00", + 27.35913685931049 + ] + ] + }, + "weights_x": [ + 1332, + 1322, + 80, + 63, + 53, + 52, + 44, + 28, + 26 + ], + "input_tokens": 85080, + "output_tokens": 120, + "finetune_tokens": 0 + }, + "message": "success", + "details": "request successful", + "code": "B10", + "support": "If you have questions or need support, please email ops@nixtla.io sharing this response and ID: S6ZYXRWXZ2", + "requestID": "S6ZYXRWXZ2" +} diff --git a/tests/testthat/dashboard.nixtla.io/api/forecast_multi_series-9d2e84-POST.json b/tests/testthat/dashboard.nixtla.io/api/forecast_multi_series-9d2e84-POST.json new file mode 100644 index 0000000..a45cdc4 --- /dev/null +++ b/tests/testthat/dashboard.nixtla.io/api/forecast_multi_series-9d2e84-POST.json @@ -0,0 +1,622 @@ +{ + "status": 200, + "data": { + "forecast": { + "columns": [ + "unique_id", + "ds", + "TimeGPT" + ], + "data": [ + [ + "BE", + "2016-12-31 00:00:00", + 45.190452575683594 + ], + [ + "BE", + "2016-12-31 01:00:00", + 43.24444580078125 + ], + [ + "BE", + "2016-12-31 02:00:00", + 41.95838928222656 + ], + [ + "BE", + "2016-12-31 03:00:00", + 39.796485900878906 + ], + [ + "BE", + "2016-12-31 04:00:00", + 39.204532623291016 + ], + [ + "BE", + "2016-12-31 05:00:00", + 40.10877990722656 + ], + [ + "BE", + "2016-12-31 06:00:00", + 43.34886932373047 + ], + [ + "BE", + "2016-12-31 07:00:00", + 48.455711364746094 + ], + [ + "BE", + "2016-12-31 08:00:00", + 54.38892364501953 + ], + [ + "BE", + "2016-12-31 09:00:00", + 55.92976379394531 + ], + [ + "BE", + "2016-12-31 10:00:00", + 55.57164764404297 + ], + [ + "BE", + "2016-12-31 11:00:00", + 54.2220458984375 + ], + [ + "BE", + "2016-12-31 12:00:00", + 52.68199157714844 + ], + [ + "BE", + "2016-12-31 13:00:00", + 51.62413024902344 + ], + [ + "BE", + "2016-12-31 14:00:00", + 51.51112365722656 + ], + [ + "BE", + "2016-12-31 15:00:00", + 54.010162353515625 + ], + [ + "BE", + "2016-12-31 16:00:00", + 57.16205596923828 + ], + [ + "BE", + "2016-12-31 17:00:00", + 61.22026062011719 + ], + [ + "BE", + "2016-12-31 18:00:00", + 62.06513977050781 + ], + [ + "BE", + "2016-12-31 19:00:00", + 59.04737854003906 + ], + [ + "BE", + "2016-12-31 20:00:00", + 55.35999298095703 + ], + [ + "BE", + "2016-12-31 21:00:00", + 51.852272033691406 + ], + [ + "BE", + "2016-12-31 22:00:00", + 50.590476989746094 + ], + [ + "BE", + "2016-12-31 23:00:00", + 48.92185974121094 + ], + [ + "DE", + "2017-12-31 00:00:00", + -0.24724960327148438 + ], + [ + "DE", + "2017-12-31 01:00:00", + -1.9071083068847656 + ], + [ + "DE", + "2017-12-31 02:00:00", + -3.1054420471191406 + ], + [ + "DE", + "2017-12-31 03:00:00", + -3.2229766845703125 + ], + [ + "DE", + "2017-12-31 04:00:00", + -3.3456268310546875 + ], + [ + "DE", + "2017-12-31 05:00:00", + -2.3639450073242188 + ], + [ + "DE", + "2017-12-31 06:00:00", + -1.7124366760253906 + ], + [ + "DE", + "2017-12-31 07:00:00", + -0.9053115844726562 + ], + [ + "DE", + "2017-12-31 08:00:00", + 0.5612297058105469 + ], + [ + "DE", + "2017-12-31 09:00:00", + 1.9465141296386719 + ], + [ + "DE", + "2017-12-31 10:00:00", + 2.397075653076172 + ], + [ + "DE", + "2017-12-31 11:00:00", + 2.942707061767578 + ], + [ + "DE", + "2017-12-31 12:00:00", + 3.21575927734375 + ], + [ + "DE", + "2017-12-31 13:00:00", + 3.3599586486816406 + ], + [ + "DE", + "2017-12-31 14:00:00", + 3.9961013793945312 + ], + [ + "DE", + "2017-12-31 15:00:00", + 4.823101043701172 + ], + [ + "DE", + "2017-12-31 16:00:00", + 4.9681243896484375 + ], + [ + "DE", + "2017-12-31 17:00:00", + 5.674430847167969 + ], + [ + "DE", + "2017-12-31 18:00:00", + 6.163536071777344 + ], + [ + "DE", + "2017-12-31 19:00:00", + 5.7597198486328125 + ], + [ + "DE", + "2017-12-31 20:00:00", + 4.083599090576172 + ], + [ + "DE", + "2017-12-31 21:00:00", + 2.9927520751953125 + ], + [ + "DE", + "2017-12-31 22:00:00", + 1.9278450012207031 + ], + [ + "DE", + "2017-12-31 23:00:00", + -0.0162811279296875 + ], + [ + "FR", + "2016-12-31 00:00:00", + 63.240081787109375 + ], + [ + "FR", + "2016-12-31 01:00:00", + 59.24473571777344 + ], + [ + "FR", + "2016-12-31 02:00:00", + 55.723838806152344 + ], + [ + "FR", + "2016-12-31 03:00:00", + 52.209632873535156 + ], + [ + "FR", + "2016-12-31 04:00:00", + 51.02058410644531 + ], + [ + "FR", + "2016-12-31 05:00:00", + 53.5487060546875 + ], + [ + "FR", + "2016-12-31 06:00:00", + 58.21989440917969 + ], + [ + "FR", + "2016-12-31 07:00:00", + 64.41748809814453 + ], + [ + "FR", + "2016-12-31 08:00:00", + 68.54605102539062 + ], + [ + "FR", + "2016-12-31 09:00:00", + 69.43729400634766 + ], + [ + "FR", + "2016-12-31 10:00:00", + 68.75494384765625 + ], + [ + "FR", + "2016-12-31 11:00:00", + 67.91847229003906 + ], + [ + "FR", + "2016-12-31 12:00:00", + 66.1435317993164 + ], + [ + "FR", + "2016-12-31 13:00:00", + 62.43498229980469 + ], + [ + "FR", + "2016-12-31 14:00:00", + 59.81889343261719 + ], + [ + "FR", + "2016-12-31 15:00:00", + 61.035003662109375 + ], + [ + "FR", + "2016-12-31 16:00:00", + 63.111297607421875 + ], + [ + "FR", + "2016-12-31 17:00:00", + 70.69346618652344 + ], + [ + "FR", + "2016-12-31 18:00:00", + 73.90049743652344 + ], + [ + "FR", + "2016-12-31 19:00:00", + 73.69876861572266 + ], + [ + "FR", + "2016-12-31 20:00:00", + 71.09501647949219 + ], + [ + "FR", + "2016-12-31 21:00:00", + 67.445556640625 + ], + [ + "FR", + "2016-12-31 22:00:00", + 65.951904296875 + ], + [ + "FR", + "2016-12-31 23:00:00", + 62.771888732910156 + ], + [ + "NP", + "2018-12-24 00:00:00", + 51.033172607421875 + ], + [ + "NP", + "2018-12-24 01:00:00", + 50.12208938598633 + ], + [ + "NP", + "2018-12-24 02:00:00", + 49.71585464477539 + ], + [ + "NP", + "2018-12-24 03:00:00", + 49.13131332397461 + ], + [ + "NP", + "2018-12-24 04:00:00", + 49.641170501708984 + ], + [ + "NP", + "2018-12-24 05:00:00", + 51.29006576538086 + ], + [ + "NP", + "2018-12-24 06:00:00", + 53.28921890258789 + ], + [ + "NP", + "2018-12-24 07:00:00", + 55.38706588745117 + ], + [ + "NP", + "2018-12-24 08:00:00", + 56.115516662597656 + ], + [ + "NP", + "2018-12-24 09:00:00", + 56.09071350097656 + ], + [ + "NP", + "2018-12-24 10:00:00", + 55.813716888427734 + ], + [ + "NP", + "2018-12-24 11:00:00", + 55.52851867675781 + ], + [ + "NP", + "2018-12-24 12:00:00", + 55.7847900390625 + ], + [ + "NP", + "2018-12-24 13:00:00", + 55.709617614746094 + ], + [ + "NP", + "2018-12-24 14:00:00", + 55.3892707824707 + ], + [ + "NP", + "2018-12-24 15:00:00", + 56.03938674926758 + ], + [ + "NP", + "2018-12-24 16:00:00", + 57.58835220336914 + ], + [ + "NP", + "2018-12-24 17:00:00", + 59.171669006347656 + ], + [ + "NP", + "2018-12-24 18:00:00", + 58.9607048034668 + ], + [ + "NP", + "2018-12-24 19:00:00", + 56.43702697753906 + ], + [ + "NP", + "2018-12-24 20:00:00", + 54.62592697143555 + ], + [ + "NP", + "2018-12-24 21:00:00", + 53.492652893066406 + ], + [ + "NP", + "2018-12-24 22:00:00", + 52.30442428588867 + ], + [ + "NP", + "2018-12-24 23:00:00", + 50.93275451660156 + ], + [ + "PJM", + "2018-12-24 00:00:00", + 21.008119583129883 + ], + [ + "PJM", + "2018-12-24 01:00:00", + 20.60911750793457 + ], + [ + "PJM", + "2018-12-24 02:00:00", + 20.260807037353516 + ], + [ + "PJM", + "2018-12-24 03:00:00", + 20.296545028686523 + ], + [ + "PJM", + "2018-12-24 04:00:00", + 21.065902709960938 + ], + [ + "PJM", + "2018-12-24 05:00:00", + 20.480093002319336 + ], + [ + "PJM", + "2018-12-24 06:00:00", + 23.40868377685547 + ], + [ + "PJM", + "2018-12-24 07:00:00", + 27.09423828125 + ], + [ + "PJM", + "2018-12-24 08:00:00", + 28.25070571899414 + ], + [ + "PJM", + "2018-12-24 09:00:00", + 28.379547119140625 + ], + [ + "PJM", + "2018-12-24 10:00:00", + 27.78171730041504 + ], + [ + "PJM", + "2018-12-24 11:00:00", + 26.666141510009766 + ], + [ + "PJM", + "2018-12-24 12:00:00", + 25.683338165283203 + ], + [ + "PJM", + "2018-12-24 13:00:00", + 24.544357299804688 + ], + [ + "PJM", + "2018-12-24 14:00:00", + 24.27858543395996 + ], + [ + "PJM", + "2018-12-24 15:00:00", + 24.576183319091797 + ], + [ + "PJM", + "2018-12-24 16:00:00", + 26.073471069335938 + ], + [ + "PJM", + "2018-12-24 17:00:00", + 32.80261993408203 + ], + [ + "PJM", + "2018-12-24 18:00:00", + 33.22092819213867 + ], + [ + "PJM", + "2018-12-24 19:00:00", + 32.02828598022461 + ], + [ + "PJM", + "2018-12-24 20:00:00", + 30.907085418701172 + ], + [ + "PJM", + "2018-12-24 21:00:00", + 28.066879272460938 + ], + [ + "PJM", + "2018-12-24 22:00:00", + 25.063722610473633 + ], + [ + "PJM", + "2018-12-24 23:00:00", + 23.301254272460938 + ] + ] + }, + "input_tokens": 8400, + "output_tokens": 120, + "finetune_tokens": 0 + }, + "message": "success", + "details": "request successful", + "code": "B10", + "support": "If you have questions or need support, please email ops@nixtla.io sharing this response and ID: 2BLK8REUXE", + "requestID": "2BLK8REUXE" +} diff --git a/tests/testthat/dashboard.nixtla.io/api/forecast_multi_series-c8b6a1-POST.json b/tests/testthat/dashboard.nixtla.io/api/forecast_multi_series-c8b6a1-POST.json new file mode 100644 index 0000000..13522c6 --- /dev/null +++ b/tests/testthat/dashboard.nixtla.io/api/forecast_multi_series-c8b6a1-POST.json @@ -0,0 +1,633 @@ +{ + "status": 200, + "data": { + "forecast": { + "columns": [ + "unique_id", + "ds", + "TimeGPT" + ], + "data": [ + [ + "BE", + "2016-12-31 00:00:00", + 74.54077259602315 + ], + [ + "BE", + "2016-12-31 01:00:00", + 43.344289274267666 + ], + [ + "BE", + "2016-12-31 02:00:00", + 44.42922020357467 + ], + [ + "BE", + "2016-12-31 03:00:00", + 38.09439509672264 + ], + [ + "BE", + "2016-12-31 04:00:00", + 37.38914113497819 + ], + [ + "BE", + "2016-12-31 05:00:00", + 39.08574109530534 + ], + [ + "BE", + "2016-12-31 06:00:00", + 42.945286252144726 + ], + [ + "BE", + "2016-12-31 07:00:00", + 41.294235898095195 + ], + [ + "BE", + "2016-12-31 08:00:00", + 48.35958324598505 + ], + [ + "BE", + "2016-12-31 09:00:00", + 56.101556413548934 + ], + [ + "BE", + "2016-12-31 10:00:00", + 55.16523822416974 + ], + [ + "BE", + "2016-12-31 11:00:00", + 54.15711101050361 + ], + [ + "BE", + "2016-12-31 12:00:00", + 53.5014752650505 + ], + [ + "BE", + "2016-12-31 13:00:00", + 94.65871557140909 + ], + [ + "BE", + "2016-12-31 14:00:00", + 47.1258567010379 + ], + [ + "BE", + "2016-12-31 15:00:00", + 44.466736114558664 + ], + [ + "BE", + "2016-12-31 16:00:00", + 46.618250561791484 + ], + [ + "BE", + "2016-12-31 17:00:00", + 55.05334153324033 + ], + [ + "BE", + "2016-12-31 18:00:00", + 50.16926113334454 + ], + [ + "BE", + "2016-12-31 19:00:00", + 46.70009368853968 + ], + [ + "BE", + "2016-12-31 20:00:00", + 46.40987888541974 + ], + [ + "BE", + "2016-12-31 21:00:00", + 44.29971977186849 + ], + [ + "BE", + "2016-12-31 22:00:00", + 47.665925812327 + ], + [ + "BE", + "2016-12-31 23:00:00", + 40.72145333467065 + ], + [ + "DE", + "2017-12-31 00:00:00", + -31.295775916483365 + ], + [ + "DE", + "2017-12-31 01:00:00", + -22.184954600736795 + ], + [ + "DE", + "2017-12-31 02:00:00", + -9.493253899038336 + ], + [ + "DE", + "2017-12-31 03:00:00", + -8.152627362314327 + ], + [ + "DE", + "2017-12-31 04:00:00", + -4.975538910071201 + ], + [ + "DE", + "2017-12-31 05:00:00", + -4.709152877966709 + ], + [ + "DE", + "2017-12-31 06:00:00", + -5.6067361755738645 + ], + [ + "DE", + "2017-12-31 07:00:00", + -7.4550841864215585 + ], + [ + "DE", + "2017-12-31 08:00:00", + -8.12062282604029 + ], + [ + "DE", + "2017-12-31 09:00:00", + -19.75437636892527 + ], + [ + "DE", + "2017-12-31 10:00:00", + -20.333697276518045 + ], + [ + "DE", + "2017-12-31 11:00:00", + -35.70595111981811 + ], + [ + "DE", + "2017-12-31 12:00:00", + -66.51799568941819 + ], + [ + "DE", + "2017-12-31 13:00:00", + -72.25607036951848 + ], + [ + "DE", + "2017-12-31 14:00:00", + -71.92610287073919 + ], + [ + "DE", + "2017-12-31 15:00:00", + -71.15767597559758 + ], + [ + "DE", + "2017-12-31 16:00:00", + -36.03780221623819 + ], + [ + "DE", + "2017-12-31 17:00:00", + -25.11167902495744 + ], + [ + "DE", + "2017-12-31 18:00:00", + -5.178491903650908 + ], + [ + "DE", + "2017-12-31 19:00:00", + -8.93198933562109 + ], + [ + "DE", + "2017-12-31 20:00:00", + -14.151304138735668 + ], + [ + "DE", + "2017-12-31 21:00:00", + -19.97155089895457 + ], + [ + "DE", + "2017-12-31 22:00:00", + -20.92338843862742 + ], + [ + "DE", + "2017-12-31 23:00:00", + -22.213898616239725 + ], + [ + "FR", + "2016-12-31 00:00:00", + 93.69808083994201 + ], + [ + "FR", + "2016-12-31 01:00:00", + 59.289256278725105 + ], + [ + "FR", + "2016-12-31 02:00:00", + 58.40772066815361 + ], + [ + "FR", + "2016-12-31 03:00:00", + 51.42690810341025 + ], + [ + "FR", + "2016-12-31 04:00:00", + 49.8274405190643 + ], + [ + "FR", + "2016-12-31 05:00:00", + 52.208793897360195 + ], + [ + "FR", + "2016-12-31 06:00:00", + 57.295197692543304 + ], + [ + "FR", + "2016-12-31 07:00:00", + 56.09739335775504 + ], + [ + "FR", + "2016-12-31 08:00:00", + 61.79573089007817 + ], + [ + "FR", + "2016-12-31 09:00:00", + 69.20394522584874 + ], + [ + "FR", + "2016-12-31 10:00:00", + 68.16339282861611 + ], + [ + "FR", + "2016-12-31 11:00:00", + 66.10206770682936 + ], + [ + "FR", + "2016-12-31 12:00:00", + 65.54767491857623 + ], + [ + "FR", + "2016-12-31 13:00:00", + 106.54351948216139 + ], + [ + "FR", + "2016-12-31 14:00:00", + 55.04072555495253 + ], + [ + "FR", + "2016-12-31 15:00:00", + 51.2055969348997 + ], + [ + "FR", + "2016-12-31 16:00:00", + 53.002243363858554 + ], + [ + "FR", + "2016-12-31 17:00:00", + 63.11358898065425 + ], + [ + "FR", + "2016-12-31 18:00:00", + 59.94209735882046 + ], + [ + "FR", + "2016-12-31 19:00:00", + 57.71339093388798 + ], + [ + "FR", + "2016-12-31 20:00:00", + 58.993652992365384 + ], + [ + "FR", + "2016-12-31 21:00:00", + 57.96052269453732 + ], + [ + "FR", + "2016-12-31 22:00:00", + 60.98328491367249 + ], + [ + "FR", + "2016-12-31 23:00:00", + 51.95414278412694 + ], + [ + "NP", + "2018-12-24 00:00:00", + 50.998705925260616 + ], + [ + "NP", + "2018-12-24 01:00:00", + 49.753014352557294 + ], + [ + "NP", + "2018-12-24 02:00:00", + 49.766680505511395 + ], + [ + "NP", + "2018-12-24 03:00:00", + 49.692939546343915 + ], + [ + "NP", + "2018-12-24 04:00:00", + 49.67919805311882 + ], + [ + "NP", + "2018-12-24 05:00:00", + 50.992008270536495 + ], + [ + "NP", + "2018-12-24 06:00:00", + 51.547055035224986 + ], + [ + "NP", + "2018-12-24 07:00:00", + 53.757655142776066 + ], + [ + "NP", + "2018-12-24 08:00:00", + 54.96587353829956 + ], + [ + "NP", + "2018-12-24 09:00:00", + 58.18303841834125 + ], + [ + "NP", + "2018-12-24 10:00:00", + 59.30602568676899 + ], + [ + "NP", + "2018-12-24 11:00:00", + 58.34717282336318 + ], + [ + "NP", + "2018-12-24 12:00:00", + 55.4861651439583 + ], + [ + "NP", + "2018-12-24 13:00:00", + 55.355408765784475 + ], + [ + "NP", + "2018-12-24 14:00:00", + 55.270492650977346 + ], + [ + "NP", + "2018-12-24 15:00:00", + 55.11098776053545 + ], + [ + "NP", + "2018-12-24 16:00:00", + 52.87967378114751 + ], + [ + "NP", + "2018-12-24 17:00:00", + 52.08690451778381 + ], + [ + "NP", + "2018-12-24 18:00:00", + 50.99290766299118 + ], + [ + "NP", + "2018-12-24 19:00:00", + 49.24441132198188 + ], + [ + "NP", + "2018-12-24 20:00:00", + 49.429914327963324 + ], + [ + "NP", + "2018-12-24 21:00:00", + 48.137836361407906 + ], + [ + "NP", + "2018-12-24 22:00:00", + 47.208843554937886 + ], + [ + "NP", + "2018-12-24 23:00:00", + 47.12802156397109 + ], + [ + "PJM", + "2018-12-24 00:00:00", + 23.075717332376897 + ], + [ + "PJM", + "2018-12-24 01:00:00", + 22.27713547855734 + ], + [ + "PJM", + "2018-12-24 02:00:00", + 22.577886990415728 + ], + [ + "PJM", + "2018-12-24 03:00:00", + 23.459224156248247 + ], + [ + "PJM", + "2018-12-24 04:00:00", + 24.618181637632524 + ], + [ + "PJM", + "2018-12-24 05:00:00", + 22.98238222967354 + ], + [ + "PJM", + "2018-12-24 06:00:00", + 22.6213325789221 + ], + [ + "PJM", + "2018-12-24 07:00:00", + 22.18442771085489 + ], + [ + "PJM", + "2018-12-24 08:00:00", + 28.43632728732061 + ], + [ + "PJM", + "2018-12-24 09:00:00", + 32.10124833017661 + ], + [ + "PJM", + "2018-12-24 10:00:00", + 31.658370789722078 + ], + [ + "PJM", + "2018-12-24 11:00:00", + 31.122157842265203 + ], + [ + "PJM", + "2018-12-24 12:00:00", + 30.65040949021442 + ], + [ + "PJM", + "2018-12-24 13:00:00", + 29.98697310371744 + ], + [ + "PJM", + "2018-12-24 14:00:00", + 29.657021340564363 + ], + [ + "PJM", + "2018-12-24 15:00:00", + 29.204463776782625 + ], + [ + "PJM", + "2018-12-24 16:00:00", + 29.418534573749177 + ], + [ + "PJM", + "2018-12-24 17:00:00", + 35.63065592475516 + ], + [ + "PJM", + "2018-12-24 18:00:00", + 31.75408989012567 + ], + [ + "PJM", + "2018-12-24 19:00:00", + 34.6047677134302 + ], + [ + "PJM", + "2018-12-24 20:00:00", + 35.13864855870446 + ], + [ + "PJM", + "2018-12-24 21:00:00", + 32.8505998145028 + ], + [ + "PJM", + "2018-12-24 22:00:00", + 31.512607142476064 + ], + [ + "PJM", + "2018-12-24 23:00:00", + 27.35913685931049 + ] + ] + }, + "weights_x": [ + 1332, + 1322, + 80, + 63, + 53, + 52, + 44, + 28, + 26 + ], + "input_tokens": 85080, + "output_tokens": 120, + "finetune_tokens": 0 + }, + "message": "success", + "details": "request successful", + "code": "B10", + "support": "If you have questions or need support, please email ops@nixtla.io sharing this response and ID: S6ZYXRWXZ2", + "requestID": "S6ZYXRWXZ2" +} diff --git a/vignettes/exogenous-variables.Rmd b/vignettes/exogenous-variables.Rmd new file mode 100644 index 0000000..f7c9bda --- /dev/null +++ b/vignettes/exogenous-variables.Rmd @@ -0,0 +1,81 @@ +--- +title: "Exogenous Variables" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Exogenous Variables} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- +```{r setup, include=FALSE} +library(httptest2) +.mockPaths("../tests/mocks") +start_vignette(dir = "../tests/mocks") + +options("NIXTLA_API_KEY"="dummy_api_key") +options(digits=7) + +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.width = 7, + fig.height = 4 +) +``` + +```{r} +library(nixtlar) +``` + +## 1. Exogenous variables + +Exogenous variables are external factors that provide additional information about the behavior of the target variable in time series forecasting. These variables, which are correlated with the target, can significantly improve predictions. Examples of exogenous variables include weather data, economic indicators, holiday markers, and promotional sales. + +`TimeGPT` allows you to include exogenous variables when generating a forecast. This vignette will show you how to include them. It assumes you have already set up your API key. If you haven't done this, please read the [Get Started](https://nixtla.github.io/nixtlar/articles/anomaly-detection.html) vignette first. + +## 2. Load data + +For this vignette, we will use the electricity consumption dataset with exogenous variables included in `nixtlar`. This dataset contains hourly prices from five different electricity markets, along with two exogenous variables related to the prices and binary variables indicating the day of the week. + +````{r} +df_exo_vars <- nixtlar::electricity_exo_vars +head(df_exo_vars) +```` + +When using exogenous variables, you must provide their future values to cover the complete forecast horizon; otherwise, `TimeGPT` will result in an error. Ensure that the dates of the future exogenous variables exactly match the forecast horizon. For the electricity consumption dataset with exogenous variables, `nixtlar` provides their values for the next 24 steps ahead. + +````{r} +future_exo_vars <- nixtlar::electricity_future_exo_vars +head(future_exo_vars) +```` + +## 3. Forecast with exogenous variables + +To generate a forecast with exogenous variables, use the `nixtla_client_forecast` function as you would for forecasts without them. The only difference is that you must add the exogenous variables using the `X_df` argument. + +Keep in mind that the default names for the time and target columns are `ds` and `y`, respectively. If your time and target columns have different names, specify them with `time_col` and `target_col`. Since this dataset has multiple ids (one for every electricity market), you will need to specify the name of the column that contains these ids, which in this case is `unique_id`. To do this, simply use `id_col="unique_id"`. + +````{r} +fcst_exo_vars <- nixtla_client_forecast(df_exo_vars, h = 24, id_col = "unique_id", X_df = future_exo_vars) +head(fcst_exo_vars) +```` + +For comparison, we will also generate a forecast without the exogenous variables. + +````{r} +df <- nixtlar::electricity # same dataset but without the exogenous variables + +fcst <- nixtla_client_forecast(df, h = 24, id_col = "unique_id") +head(fcst) +```` + +## 4. Plot TimeGPT forecast + +`nixtlar` includes a function to plot the historical data and any output from `nixtla_client_forecast`, `nixtla_client_historic`, `nixtla_client_anomaly_detection` and `nixtla_client_cross_validation`. If you have long series, you can use `max_insample_length` to only plot the last N historical values (the forecast will always be plotted in full). + +```{r} +nixtla_client_plot(df_exo_vars, fcst_exo_vars, id_col = "unique_id", max_insample_length = 500) +``` + +```{r, include=FALSE} +end_vignette() +```