plot_trace: Plot posterior samples over time

Description Usage Arguments Value Examples

View source: R/plot.R

Description

Plot posterior samples over time

Usage

 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"
)

Arguments

draws

A data frame as produced by posterior_samples()

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 TRUE.

y_label

Character string indicating the y axis label to use.

Value

A ggplot2 object.

Examples

 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)

epiforecasts/covid19.track.severity documentation built on July 6, 2021, 4:50 p.m.