From 92bd21cd5edffa0776b54594ad17c39b6fd59196 Mon Sep 17 00:00:00 2001 From: VP Nagraj Date: Sun, 5 May 2024 10:13:06 -0400 Subject: [PATCH 1/4] conditionally includes nnetar in the ensemble forecast if specified in model list --- R/forecast.R | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/R/forecast.R b/R/forecast.R index 9975b7e..f10018b 100644 --- a/R/forecast.R +++ b/R/forecast.R @@ -122,10 +122,13 @@ ts_fit_forecast <- function(prepped_tsibble, # e.g. if an ARIMA model doesn't fit for one location but the ETS does, you still want the ETS model for that location. tsfit <- purrr::reduce(tsfit, dplyr::inner_join, by="location") - # Ensemble the ARIMA and ETS models - # Hard-coded for now - can always ensemble other models if/when we add them. - # fixme: this could be more flexible - if (ensemble & !is.null(models$arima) & !is.null(models$ets)) { + # Ensemble the models + # TODO: make this more flexible and not hard-coded in the future? + if (ensemble & !is.null(models$arima) & !is.null(models$ets) & !is.null(models$nnetar)) { + tsfit <- + tsfit %>% + dplyr::mutate(ensemble=(arima+ets+nnetar)/3) + } else if (ensemble & !is.null(models$arima) & !is.null(models$ets)) { tsfit <- tsfit %>% dplyr::mutate(ensemble=(arima+ets)/2) From e5138de01dde62174ba5e439969077db707d5c24 Mon Sep 17 00:00:00 2001 From: VP Nagraj Date: Sun, 5 May 2024 10:19:25 -0400 Subject: [PATCH 2/4] adds nnetar to list of global variables per check NOTE --- R/fiphde-package.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/fiphde-package.R b/R/fiphde-package.R index 8e7e14e..41f3c99 100644 --- a/R/fiphde-package.R +++ b/R/fiphde-package.R @@ -132,5 +132,6 @@ if(getRversion() >= "2.15.1") utils::globalVariables(c(".", "reference_date", "target_name", "target_prob", + "nnetar", ".")) From 264dbd93a366d04ce29eea32803543a368c5755a Mon Sep 17 00:00:00 2001 From: VP Nagraj Date: Sun, 5 May 2024 10:19:44 -0400 Subject: [PATCH 3/4] increments to v2.0.2 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0803232..c12b0ee 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: fiphde Title: Forecasting Influenza in Support of Public Health Decision Making -Version: 2.0.1 +Version: 2.0.2 Authors@R: c(person(given = "VP", family = "Nagraj", From 44704f3e164ed30997e1090f3e7a38c57f75fc89 Mon Sep 17 00:00:00 2001 From: VP Nagraj Date: Sun, 5 May 2024 12:11:31 -0400 Subject: [PATCH 4/4] updates the v2.0.2 changelog --- NEWS.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS.md b/NEWS.md index 782bbb3..ec1bc16 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +# fiphde 2.0.2 + +## New features + +### NNETAR in ensemble + +As of this release, if the NNETAR model is specified in the `ts_fit_forecast()` function (i.e., "nnetar" is not `NULL` in the model list) then the model will be included in the ensemble. In previous releases, if the NNETAR method was used the results would be included in the returned forecast and fit objects but would not be ensembled with the other components. Note that currently *all* of the possible models (ARIMA, ETS, and NNETAR) must be specified to use the NNETAR in the ensemble. + # fiphde 2.0.1 ## Bug fixes