# NOT RUN {
data("EuropeCovid2")
data <- EuropeCovid2$data
data <- dplyr::filter(data, date > date[which(cumsum(deaths) > 10)[1] - 30])
data <- dplyr::filter(data, date < as.Date("2020-05-05"))
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 <- 1e-3
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("2020-03-21", NA)) # plot 21 March 2020 onwards
p <- plot_rt(fm, dates=c(NA, "2020-03-20")) # plot up to 20 March 2020
p <- plot_rt(fm, dates=c("2020-03-20", "2020-04-20"))
p <- plot_rt(fm,
dates=c("2020-03-20", "2020-04-20"),
date_breaks="1 day") # ticks every day
p <- plot_rt(fm,
dates=c("2020-20-03", "2020-20-04"),
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)
# }
Run the code above in your browser using DataLab