A call to rw can be used in the 'formula' argument of epim, allowing random walks for the reproduction number. Does not evaluate arguments. Simply creates a list with the information needed for the stan data to be parsed correctly.

rw(time, gr, prior_scale = 0.2, noncentred = FALSE)

Arguments

time

An optional name defining the random walk time periods for each date and group. This must be a column name found in the data argument to epim. If not specified, determined by the dates column implied by the formula argument to epim is used. Rows whose time is NA have no random walk term. Giving NA to the first period of each group (and to any seeding days before it) starts the walk in the second period: the first period's value is then the intercept alone, and each later period adds a step. With a normal(0, s) prior on a group intercept, the first period's log Rt is normal(0, s), followed by a driftless walk.

gr

Same as for time, except this defines the grouping to use for the random walks. A separate walk is defined for each group. If not specified a common random walk is used for all groups.

prior_scale

The steps of the walks are independent zero mean normal with an unknown scale hyperparameter. This scale is given a half-normal prior. prior_scale sets the scale parameter of this hyperprior.

noncentred

If TRUE, the steps are sampled as standard normal variables and then multiplied by the scale (a non-centred parameterisation). This is the same model, but often easier to sample when the scale is close to zero. The reported steps are the same either way. Defaults to FALSE.

Value

A list to be parsed internally.

Examples


data("EuropeCovid")
args <- EuropeCovid
args$formula <- R(country, date) ~ 1 + rw(gr=country) + lockdown