Description Usage Arguments Details Value Examples
epirt defines a model for reproduction rates. For more
details on the model assumptions, please read the model description
vignette.
1 2 3 4 5 6 7 8 9 |
formula |
An object of class |
link |
The link function. This must be either |
center |
If |
prior |
Same as in |
prior_intercept |
Same as in |
prior_covariance |
Same as in |
... |
Additional arguments for |
epirt has a formula argument which defines the linear predictor, an argument link defining the link function,
and additional arguments to specify priors on parameters making up the linear predictor.
A general R formula gives a symbolic description of a model. It takes the form y ~ model, where y is the response
and model is a collection of terms separated by the + operator. model fully defines a linear predictor used to predict y.
In this case, the “response” being modeled are reproduction numbers which are unobserved.
epirt therefore requires that the left hand side of the formula takes the form R(group, date),
where group and date refer to variables representing the region and date respectively.
The right hand side can consist of fixed effects, random effects, and autocorrelation terms.
An object of class epirt.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | library(epidemia)
library(ggplot2)
data("EuropeCovid")
options(mc.cores = 2)
data <- EuropeCovid$data
data$week <- lubridate::week(data$date)
# collect arguments for epim
args <- list(
inf = epiinf(gen = EuropeCovid$si),
obs = epiobs(deaths ~ 1, i2o = EuropeCovid$inf2death, link = scaled_logit(0.02)),
data = data,
algorithm = "fullrank", # For speed - should generally use "sampling"
iter = 2e4,
group_subset = "France",
seed = 12345,
refresh = 0
)
# a simple random walk model for R
args$rt <- epirt(
formula = R(country, date) ~ rw(time = week),
link = scaled_logit(7)
)
fm1 <- do.call(epim, args)
plot_rt(fm1) + theme_bw()
# Modeling effects of NPIs
args$rt <- epirt(
formula = R(country, date) ~ 1 + lockdown + public_events,
link = scaled_logit(7)
)
fm2 <- do.call(epim, args)
plot_rt(fm2) + theme_bw()
# shifted gamma prior for NPI effects
args$rt <- epirt(
formula = R(country, date) ~ 1 + lockdown + public_events,
link = scaled_logit(7),
prior = shifted_gamma(shape = 1/2, scale = 1, shift = log(1.05)/2)
)
# How does the implied prior look?
args$prior_PD <- TRUE
fm3 <- do.call(epim, args)
plot_rt(fm3) + theme_bw()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.