geom_bands: ggplot2 geom for Quantile Bands

Description Usage Arguments Details Examples

View source: R/plot.R

Description

Plots quantile bands given a data.frame with stochastic model results from icm or netsim.

Usage

1
geom_bands(mapping, lower = 0.25, upper = 0.75, alpha = 0.25, ...)

Arguments

mapping

standard aesthetic mapping aes() input for ggplot2.

lower

Lower quantile for the time series.

upper

Upper quantile for the time series.

alpha

Transparency of the ribbon fill.

...

Additional arguments passed to stat_summary.

Details

This is a wrapper around ggplot::stat_summary with a ribbon geom as aesthetic output.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
param <- param.icm(inf.prob = 0.2, act.rate = 0.25)
init <- init.icm(s.num = 500, i.num = 1)
control <- control.icm(type = "SI", nsteps = 250, nsims = 5)
mod1 <- icm(param, init, control)
df <- as.data.frame(mod1)
df.mean <- as.data.frame(mod1, out = "mean")

library(ggplot2)
ggplot() +
   geom_line(data = df, mapping = aes(time, i.num, group = sim),
   alpha = 0.25, lwd = 0.25, color = "firebrick") +
   geom_bands(data = df, mapping = aes(time, i.num),
              lower = 0.1, upper = 0.9, fill = "firebrick") +
   geom_line(data = df.mean, mapping = aes(time, i.num)) +
   theme_minimal()

EpiModel documentation built on Feb. 2, 2022, 9:06 a.m.