Given a fitted nowcast and new data that arrived after the fit, compute how surprising the new data is under the fitted posterior.
Two types of surprise are supported (select via the type argument):
"count": How surprising is a new case count at a given event time"delay": How surprising is a report with a very long delay"both": Compute both (requires appropriatenew_dataformat).
Usage
surprise(
object,
new_data,
type = c("both", "count", "delay"),
level = 0.99,
n_draws = 500L,
seed = sample.int(.Machine$integer.max, 1)
)Arguments
- object
A
nowcast_classobject (orfit()result).- new_data
For
type = "count": a data.frame with columnsevent_index(0-indexed) andcount(observed new total at that time). Fortype = "delay": a data.frame with columnsdelay(numeric delay values) and optionallyweight(counts with that delay, default 1). Fortype = "both": supply both sets of columns.- type
Which surprise type(s) to compute. One of
"count","delay","both"(default"both").- level
Credible level used to flag surprises (default
0.99). A count is flagged when it falls in the outer(1 - level)/2tail of the posterior predictive (too high or too low); a delay is flagged whenP(D >= d)orP(D <= d)is below1 - level(surprisingly long or short).- n_draws
Number of posterior draws (default 500).
- seed
Optional RNG seed.
