Closed stephenturner closed 3 years ago
didnt realize you were putting the hospitalization edits in here too. just seeing that you changed the title. was reviewing but do you want me to wait until you're done?
I didn't realize I was either. This started out to put in a function to create sanity check plots as in #21, as I was kicking around trying to see if including hospitalization data would help the ideath forecast. Then found some issues with functions that don't like ihosp (or anything besides icases/ideaths). I reverted back to draft, will ping you after I push up just a few more things. I branched off of the state-level-ts
branch so merging into that one is probably easiest. more to follow.
cool. im going to go ahead and merge what's in the state-level-ts for now. but i might leave that branch open so we can keep adding code there as we actually move to implement the state forecasts with our time series models
@vpnagraj ok you can go ahead and review / merge. Still more to do if we want to add hospitalization data but I need some time to put together some reproducible examples of some oddities I'm seeing.
Once this is merged into state-level-ts, want to merge that into master? Can always open back up the new branch for more state/granular level work?
sounds good i'll review now.
if G2G i will merge directly to state-level-ts => master and leave state-level-ts open
do it. if it closes automatically either of us can push the branch again
this is cool. i like that we will be able to use the plot_forecast()
function for other types of methods so long as we get them into the submission format. we could even make it flexbile enough to not require the data input arg at all (so we could theoretically plot forecasts from other teams)
i made a few aesthetic edits, added an argument to include the prediction interval, and made the location flexible enough to work with other location codes besides US:
myforecast <- forecast_pipeline(force=TRUE)
plot_forecast(.data = myforecast$data, submission = myforecast$submission, pi = TRUE)
## get data at the state scale from jhu source
usac <- get_cases(source="jhu", granularity = "state")
usad <- get_deaths(source="jhu", granularity = "state")
## use the focustools helper to prep the tsibble format
usa <-
dplyr::inner_join(usac, usad, by = c("epiyear", "epiweek", "location")) %>%
make_tsibble(chop=TRUE)
fit.icases <- usa %>% model(arima = ARIMA(icases, stepwise=FALSE, approximation=FALSE))
fit.ideaths <- usa %>% model(linear_caselag3 = TSLM(ideaths ~ lag(icases, 3)))
## generate incident case forecast
icases_forecast <- ts_forecast(fit.icases, outcome = "icases", horizon = 4)
icases_forecast
## need to get future cases to pass to ideaths forecast
future_cases <- ts_futurecases(usa, icases_forecast, horizon = 4)
ideaths_forecast <- ts_forecast(fit.ideaths, outcome = "ideaths", new_data = future_cases)
ideaths_forecast
cdeaths_forecast <- ts_forecast(outcome = "cdeaths", .data = usa, inc_forecast = ideaths_forecast)
cdeaths_forecast
submission <-
list(format_for_submission(icases_forecast, target_name = "inc case"),
format_for_submission(ideaths_forecast, target_name = "inc death"),
format_for_submission(cdeaths_forecast, target_name = "cum death")) %>%
reduce(bind_rows) %>%
arrange(target)
plot_forecast(.data=usa, submission=submission, location = c("34","36"), pi = TRUE)
i'm going to go ahead and merge but we can revisit this as needed