plot_obs {epidemia}  R Documentation 
Plots credible intervals and median for the observed data under the posterior predictive distribution, and for a specific observation type. The user can control the interval levels (i.e. 30%, 50% etc.) and the plotted group(s). This is a generic function.
plot_obs(object, ...)
## S3 method for class 'epimodel'
plot_obs(
object,
type,
groups = NULL,
dates = NULL,
date_breaks = "2 weeks",
date_format = "%Y%m%d",
cumulative = FALSE,
by_100k = FALSE,
bar = TRUE,
levels = c(30, 60, 90),
log = FALSE,
...
)
spaghetti_obs(
object,
type,
draws = min(500, posterior_sample_size(object)),
alpha = 1/sqrt(draws),
groups = NULL,
dates = NULL,
date_breaks = "2 weeks",
date_format = "%Y%m%d",
cumulative = FALSE,
by_100k = FALSE,
bar = TRUE,
log = FALSE,
smooth = 1,
...
)
object 
A fitted model object returned by 
... 
Additional arguments for

type 
A string specifying the name of the observations to plot. This should match one
of the names of the response variables in the 
groups 
Either 
dates 
A length 2 vector of 
date_breaks 
A string giving the distance between date tick labels.
Default is 
date_format 
This function attempts to coerce the 
cumulative 
If 
by_100k 
If 
bar 
If 
levels 
A numeric vector defining the levels of the plotted credible intervals. 
log 
If 
draws 
The number of sample paths to plot. 
alpha 
Sets transparency of sample paths. 
smooth 
An integer specifying the window used to smooth the reproduction rates. The
default is 
A ggplot
object which can be further modified.
plot_rt
, plot_infections
, plot_infectious
, posterior_predict
data("EuropeCovid2")
data < EuropeCovid2$data
data < dplyr::filter(data, date > date[which(cumsum(deaths) > 10)[1]  30])
data < dplyr::filter(data, date < as.Date("20200505"))
rt < epirt(
formula = R(country, date) ~ 0 + (1 + public_events + schools_universities +
self_isolating_if_ill + social_distancing_encouraged + lockdown  country) +
public_events + schools_universities + self_isolating_if_ill +
social_distancing_encouraged + lockdown,
prior = shifted_gamma(shape=1/6, scale = 1, shift = log(1.05)/6),
prior_covariance = rstanarm::decov(shape = c(2, rep(0.5, 5)),scale=0.25),
link = scaled_logit(6.5)
)
inf < epiinf(gen = EuropeCovid$si, seed_days = 6)
deaths < epiobs(
formula = deaths ~ 1,
i2o = EuropeCovid2$inf2death,
prior_intercept = rstanarm::normal(0,0.2),
link = scaled_logit(0.02)
)
args < list(rt=rt, inf=inf, obs=deaths, data=data, seed=12345)
args$group_subset < c("Italy", "Austria", "Germany")
args$algorithm < "fullrank"
args$iter < 1e4
args$tol_rel_obj < 1e3
fm < do.call(epim, args)
# different ways of using plot_rt
p < plot_rt(fm) # default, plots all groups and dates
p < plot_rt(fm, dates=c("20200321", NA)) # plot 21 March 2020 onwards
p < plot_rt(fm, dates=c(NA, "20200320")) # plot up to 20 March 2020
p < plot_rt(fm, dates=c("20200320", "20200420"))
p < plot_rt(fm,
dates=c("20200320", "20200420"),
date_breaks="1 day") # ticks every day
p < plot_rt(fm,
dates=c("20202003", "20202004"),
date_format="%Y%d%m") # (different date format)
# other plotting functions
p < plot_obs(fm, type = "deaths")
p < plot_infections(fm)
p < plot_infectious(fm)