Description Usage Arguments Value Examples
Plot posterior samples over time
1 2 3 4 5 6 7 8 9 10 | plot_trace(
draws,
data = NULL,
samples = 100,
alpha = 0.01,
obs_alpha = 0.8,
y_scale = "continuous",
x_axis = TRUE,
y_label = "scaling"
)
|
draws |
A data frame as produced by |
data |
A data frame of data raw data with date and value variables. |
samples |
Integer, defaults to 100. Number of samples to plot. |
alpha |
Numeric, fill intensity of the trace. Defaults to 0.01. |
obs_alpha |
Numeric, fill intensity of the observed data. Defaults to 0.8. |
y_scale |
Character string indicating the scale to use on the y axis. Options are "continuous", "log", or "percent". Default is "continuous". |
x_axis |
Logical, should the x axis labelling be included. Default is
|
y_label |
Character string indicating the y axis label to use. |
A ggplot2
object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Not run:
# load packages used
library(EpiNow2)
# set cores
options(mc.cores = ifelse(interactive(), 4 ,1))
#fit using data in the UK for cases and deaths
fit <- estimate_secondary(reports = example_obs, chains = 2,
obs = obs_opts(scale = list(mean = 0.2, sd = 0.2)))
draws <- posterior_samples(fit)
plot_trace(draws[parameter %in% "sim_secondary"],
obs[, .(date, value = secondary)],
y_label = "Admissions", samples = 100)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.