Infers max_time from a model and a tbl_now. max_time is the number of
event-time points the model spans: the epidemic process runs from t = 0 to
t = max_time - 1.
Usage
infer_max_time(data, model = diseasenowcasting::model())Details
This function is useful for building custom epidemic processes whose intensity function loops over time and therefore needs to know the number of event-times before it is written (e.g. an SIR recursion or a random walk with one innovation per time point).
Examples
library(tbl.now)
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
mpox_pooled <- mpoxdat |>
ungroup() |>
summarise(n = sum(n), .by = c(dx_date, dx_report_date))
mpox_tn <- tbl_now(mpox_pooled,
event_date = dx_date,
report_date = dx_report_date,
case_count = n,
data_type = "count-incidence",
verbose = FALSE)
# The result is 316: the model spans from time t = 0 (min event_num)
# to time t = 315 (max report_num).
infer_max_time(mpox_tn)
#> [1] 316
