Closed stephenturner closed 2 years ago
Fixes #114
remove_null_models
TRUE
Download/extract this preprocessed dataset saved from last week to demonstrate/test
pht.rds.zip
library(tidyverse) library(fiphde) prepped_tsibble <- readRDS("pht.rds") # Fit a model hosp_fitfor_all <- ts_fit_forecast(prepped_tsibble, horizon=4L, outcome="flu.admits", covariates=c("hosp_rank", "ili_rank"), stepwise=FALSE, approximation=FALSE) hosp_fitfor_all
> hosp_fitfor_all $tsfit # A mable: 1 x 4 # Key: location [1] location arima ets ensemble <chr> <model> <model> <model> 1 US <LM w/ ARIMA(2,1,0) errors> <ETS(M,A,N)> <COMBINATION> $tsfor # A fable: 12 x 10 [1W] # Key: location, .model [3] location .model yweek flu.admits .mean epiweek ili_mean ili_rank hosp_mean hosp_rank <chr> <chr> <week> <dist> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> 1 US arima 2022 W12 N(3298, 24748) 3298. 12 2.32 37 1.76 17 2 US arima 2022 W13 N(3685, 77730) 3685. 13 2.15 35 1.49 16 3 US arima 2022 W14 N(3937, 181881) 3937. 14 1.90 33 1.21 14 4 US arima 2022 W15 N(4118, 336191) 4118. 15 1.68 30 0.89 12 5 US ets 2022 W12 N(3148, 253769) 3148. 12 2.32 37 1.76 17 6 US ets 2022 W13 N(3382, 658575) 3382. 13 2.15 35 1.49 16 7 US ets 2022 W14 N(3616, 1259088) 3616. 14 1.90 33 1.21 14 8 US ets 2022 W15 N(3850, 2107647) 3850. 15 1.68 30 0.89 12 9 US ensemble 2022 W12 N(3223, 97251) 3223. 12 2.32 37 1.76 17 10 US ensemble 2022 W13 N(3533, 262937) 3533. 13 2.15 35 1.49 16 11 US ensemble 2022 W14 N(3777, 527037) 3777. 14 1.90 33 1.21 14 12 US ensemble 2022 W15 N(3984, 9e+05) 3984. 15 1.68 30 0.89 12 $formulas $formulas$arima flu.admits ~ PDQ(0, 0, 0) + pdq(1:2, 0:2, 0) + hosp_rank + ili_rank <environment: 0x7f87281907b0> $formulas$ets flu.admits ~ season(method = "N") <environment: 0x7f87281907b0> $nullmodels # A tibble: 1 × 2 location model <chr> <chr> 1 05 arima
In theory, multiple models for the same location could be null, which would return multiple rows in the $nullmodels element of the returned list. The function removes entire rows, i.e., the entire location, if any models are null.
$nullmodels
thanks for adding this check @stephenturner
all looks good to me.
Fixes #114
remove_null_models
arg to forecast function (defaultTRUE
)Download/extract this preprocessed dataset saved from last week to demonstrate/test
pht.rds.zip
In theory, multiple models for the same location could be null, which would return multiple rows in the
$nullmodels
element of the returned list. The function removes entire rows, i.e., the entire location, if any models are null.