Skip to contents

Plot a proportions timeseries

Usage

plot_proportion(
  modelled = i_proportion_model,
  raw = i_proportion_data,
  ...,
  mapping = .check_for_aes(modelled, ...),
  events = i_events
)

Arguments

modelled

Proportion model estimates - a dataframe with columns:

  • time (ggoutbreak::time_period + group_unique) - A (usually complete) set of singular observations per unit time as a `time_period`

  • proportion.fit (double) - an estimate of the proportion on a logit scale

  • proportion.se.fit (positive_double) - the standard error of proportion estimate on a logit scale

  • proportion.0.025 (proportion) - lower confidence limit of proportion (true scale)

  • proportion.0.5 (proportion) - median estimate of proportion (true scale)

  • proportion.0.975 (proportion) - upper confidence limit of proportion (true scale)

Any grouping allowed.

raw

Raw count data with denominator - a dataframe with columns:

  • denom (positive_integer) - Total test counts associated with the specified time frame

  • count (positive_integer) - Positive case counts associated with the specified time frame

  • time (ggoutbreak::time_period + group_unique) - A (usually complete) set of singular observations per unit time as a `time_period`

Any grouping allowed.

...

Named arguments passed on to geom_events

events

Significant events or time spans - a dataframe with columns:

  • label (character) - the event label

  • start (date) - the start date, or the date of the event

  • end (date) - the end date or NA if a single event

Any grouping allowed.

A default value is defined.

mapping

a ggplot2::aes mapping. Most importantly setting the colour to something if there are multiple incidence timeseries in the plot

events

Significant events or time spans - a dataframe with columns:

  • label (character) - the event label

  • start (date) - the start date, or the date of the event

  • end (date) - the end date or NA if a single event

Any grouping allowed.

A default value is defined.

Value

a ggplot object

Examples

tmp = ggoutbreak::test_poisson_rt_2class %>%
  ggoutbreak::proportion_locfit_model(window=21) %>%
  dplyr::glimpse()
#> Rows: 322
#> Columns: 20
#> Groups: class [2]
#> $ class                  <fct> one, one, one, one, one, one, one, one, one, on…
#> $ time                   <time_prd> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
#> $ proportion.fit         <dbl> -0.20764707, -0.16164731, -0.11585089, -0.07019…
#> $ proportion.se.fit      <dbl> 0.3489260, 0.3328725, 0.3174466, 0.3027491, 0.2…
#> $ proportion.0.025       <dbl> 0.2907943, 0.3070249, 0.3234340, 0.3399387, 0.3…
#> $ proportion.0.05        <dbl> 0.3139796, 0.3297814, 0.3456979, 0.3616597, 0.3…
#> $ proportion.0.25        <dbl> 0.3910278, 0.4046405, 0.4182491, 0.4318294, 0.4…
#> $ proportion.0.5         <dbl> 0.4482740, 0.4596759, 0.4710696, 0.4824597, 0.4…
#> $ proportion.0.75        <dbl> 0.5069245, 0.5157128, 0.5245461, 0.5334527, 0.5…
#> $ proportion.0.95        <dbl> 0.5905610, 0.5952903, 0.6002009, 0.6053453, 0.6…
#> $ proportion.0.975       <dbl> 0.6168585, 0.6202880, 0.6239464, 0.6278927, 0.6…
#> $ relative.growth.fit    <dbl> 0.04612401, 0.04614297, 0.04619444, 0.04627030,
#> $ relative.growth.se.fit <dbl> 0.02358606, 0.02352733, 0.02336793, 0.02313302,
#> $ relative.growth.0.025  <dbl> -1.038145e-04, 3.025148e-05, 3.941448e-04, 9.30…
#> $ relative.growth.0.05   <dbl> 0.007328397, 0.007443957, 0.007757621, 0.008219…
#> $ relative.growth.0.25   <dbl> 0.03021546, 0.03027403, 0.03043302, 0.03066731,
#> $ relative.growth.0.5    <dbl> 0.04612401, 0.04614297, 0.04619444, 0.04627030,
#> $ relative.growth.0.75   <dbl> 0.06203256, 0.06201192, 0.06195587, 0.06187328,
#> $ relative.growth.0.95   <dbl> 0.08491962, 0.08484199, 0.08463127, 0.08432073,
#> $ relative.growth.0.975  <dbl> 0.09235184, 0.09225570, 0.09199474, 0.09161018,

if(interactive()) {
  plot_proportion(tmp)+
    ggplot2::scale_fill_viridis_d(aesthetics = c("fill","colour"))
}