
Tidy a nowcast produced by run_nowcast() or nowcast_ensemble()
tidy.tbl_nowcast.RdTurns a tbl_nowcast into the same table every other tidy() method in this
package returns, so a nowcast produced through run_nowcast() and one
produced by calling a modelling package by hand are read the same way.
Arguments
- x
A tbl_nowcast.
- probs
Optional numeric vector of probabilities in
[0, 1], adding oneq*column each. Only available when the nowcast carries draws: a quantile-only nowcast cannot produce a level it was not summarised at, so asking for one is an error rather than an interpolation dressed up as a quantile.- ...
Unused, for generic consistency.
Value
A tibble with the columns documented at tidy.nowcast():
event_date, stratum, estimate, conf.low, conf.high, level and
engine, plus one q* column per element of probs.
Two of those columns are read off the object rather than assumed:
levelA
tbl_nowcastholds whatever quantile levels it was summarised at, and those need not be symmetric.levelis the width of the widest symmetric pair actually present –0.95for the defaultnowcast_quantile_levels(),0.8for a fit summarised atc(0.1, 0.5, 0.9). When no symmetric pair exists,level,conf.lowandconf.highare allNA: a guessed width defeats the point of the column.engineThe nowcast's
method, so"baselinenowcast"for a single fit and"ensemble"(or whatevernamenowcast_ensemble()was given) for a combined one.
stratum is "all" only when the nowcast declares no strata. Several strata
columns are pasted " | "-separated, matching the rest of the package, so
(stratum, event_date) is a unique key.
estimate is the 0.5 quantile, and NA when the nowcast was summarised at
levels that do not include the median.
See also
tidy.nowcast() for the same table off a raw engine fit,
run_nowcast(), nowcast_ensemble().
Examples
predictions <- tidyr::expand_grid(
onset_week = as.Date("2020-01-05") + c(0, 7),
.quantile_level = c(0.025, 0.5, 0.975)
)
predictions$.value <- c(5, 10, 18, 6, 12, 21)
nc <- tbl_nowcast(
predictions = predictions, method = "toy", event_date = "onset_week"
)
tidy(nc)
#> # A tibble: 2 × 7
#> event_date stratum estimate conf.low conf.high level engine
#> <date> <chr> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 2020-01-05 all 10 5 18 0.95 toy
#> 2 2020-01-12 all 12 6 21 0.95 toy