plot_sync: display synchronized death and confirmed case series

Description Usage Arguments Value Note Examples

View source: R/syncapp.R

Description

display synchronized death and confirmed case series

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
plot_sync(
  dfr,
  basedate = "2020-05-01",
  maxdate = Inf,
  shift = 26,
  winsize = 14,
  na_pad = TRUE,
  xlim.in = NULL,
  yspan = 0.25
)

Arguments

dfr

data.frame with columns 'date', 'deaths', 'confirmed', where the latter are 'incident', formed by differencing the cumulative counts provided in sars2pack

basedate

minimum date to consider

maxdate

maximum date to use, Inf for no limit relative to available dates

shift

number of days to backshift death counts, coerced to integer

winsize

size of running window for averaging incident counts for plotting

na_pad

logical(1) passed to runner::mean_run

xlim.in

defaults to NULL, standard graphics::plot xlim, or can be a numeric(2)

yspan

log-scale extra padding for y extent, expanding range of log(incident cases)+log cIFR

Value

a list with elements x, y, date, invisibly

Note

The 'IFR' is crudely estimated as exp(mean(log(deaths)-log(confirmed))).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
if (!exists("jh")) jh = enriched_jhu_data()
requireNamespace("dplyr")
us = dplyr::filter(jh, alpha2Code=="US")
usd =  dplyr::filter(us, subset=="deaths")
usc =  dplyr::filter(us, subset=="confirmed")
usd2 = usd[-1,]
usd2$inc = diff(usd$count)
usc2 = usc[-1,]
usc2$inc = diff(usc$count)
uss = rbind(usd2, usc2)
uscd = data.frame(date=usc2$date, confirmed=usc2$inc, deaths=usd2$inc)
plot_sync(uscd)

vjcitn/sars2app documentation built on Jan. 3, 2022, 12:19 a.m.