@@ -283,15 +283,15 @@ data.
283283
284284There are many ways we could modify ` four_week_ahead ` ; one simple modification
285285would be to include a growth rate estimate as part of the model.
286- Another would be to include a time component to the prediction (useful if we
287- expect there to be a strong seasonal component).
288286Another would be to convert from rates to counts, for example if that were the
289287preferred prediction format.
288+ Another would be to include a time component to the prediction (useful if we
289+ expect there to be a strong seasonal component).
290290
291291## Growth rate
292292
293293One feature that may potentially improve our forecast is looking at the growth
294- rate
294+ rate
295295
296296``` {r growth_rate_recipe}
297297growth_rate_recipe <- epi_recipe(
@@ -305,12 +305,17 @@ growth_rate_recipe <- epi_recipe(
305305 step_epi_naomit() |>
306306 step_training_window()
307307```
308+
308309Inspecting the newly added column:
310+
309311``` {r growth_rate_print}
310312growth_rate_recipe |>
311313 prep(training_data) |>
312314 bake(training_data) |>
313- select(geo_value, time_value, case_rate, death_rate, gr_7_rel_change_death_rate)
315+ select(
316+ geo_value, time_value, case_rate,
317+ death_rate, gr_7_rel_change_death_rate
318+ )
314319```
315320And the role:
316321``` {r growth_rate_roles}
@@ -320,7 +325,7 @@ prepped$term_info |> filter(grepl("gr", variable))
320325```
321326
322327To demonstrate the changes in the layers that come along with it, we will use
323- ` quantile_reg() ` as the model:
328+ ` quantile_reg() ` as the model, which requires changing from ` layer_residual_quantiles() ` to ` layer_quantile_distn() ` and ` layer_point_from_distn() ` :
324329``` {r layer_and_fit}
325330growth_rate_layers <- frosting() |>
326331 layer_predict() |>
@@ -347,14 +352,17 @@ gr_predictions <- gr_fit_workflow |>
347352```
348353<details >
349354<summary > Plot </summary >
355+
356+ Plotting the result; this is reusing some code from the landing page to print
357+ the forecast date.
358+
350359``` {r plotting}
351- # plotting the result
352360forecast_date_label <-
353361 tibble(
354362 geo_value = rep(used_locations, 2),
355363 .response_name = c(rep("case_rate", 4), rep("death_rate", 4)),
356364 dates = rep(forecast_date - 7 * 2, 2 * length(used_locations)),
357- heights = c(rep(150, 4), rep(0.40 , 4))
365+ heights = c(rep(150, 4), rep(0.30 , 4))
358366 )
359367
360368result_plot <- autoplot(
@@ -379,11 +387,6 @@ result_plot
379387
380388TODO ` get_test_data ` isn't actually working here...
381389
382- [ ^ 1 ] : Think of baking a cake, where adding the frosting is the last step in the process of actually baking.
383-
384- [ ^ 2 ] : Note that the frosting doesn't require any information about the training
385- data, since the output of the model only depends on the model used.
386-
387390## Population scaling
388391
389392Suppose we're sending our predictions to someone who is looking to understand
@@ -425,3 +428,8 @@ which are 2-3 orders of magnitude larger than the corresponding rates above.
425428` df ` represents the scaling value; in this case it is the state populations,
426429while ` rate_rescaling ` gives the denominator of the rate (our fit values were
427430per 100,000).
431+
432+ [ ^ 1 ] : Think of baking a cake, where adding the frosting is the last step in the process of actually baking.
433+
434+ [ ^ 2 ] : Note that the frosting doesn't require any information about the training
435+ data, since the output of the model only depends on the model used.
0 commit comments