bulk_estimate_Rt: Estimate R(t) for all locales in a case-tracking dataset

View source: R/estimate_Rt.R

bulk_estimate_RtR Documentation

Estimate R(t) for all locales in a case-tracking dataset

Description

This function can estimate R(t) curves for all locations in a case-tracking dataset and return a stacked data.frame with the location details included. It is a convenience function for getting R(t) over a large dataset. Right now, nothing is done in "parallel", so this function is not going to be much (or any) faster than running on each location in a case-tracking dataset independently and then combining.

Usage

bulk_estimate_Rt(
  df,
  grouping_columns = setdiff(colnames(df), c(cases_column, date_column)),
  cases_column = "count",
  date_column = "date",
  ...
)

Arguments

df

a data.frame containing at least a date column and a cases column, describing the cumulative cases at each date. The data.frame may contain additional columns that can be used to "group" the dates and cases to produce a set of R(t) curves.

grouping_columns

character() vector specifying the grouping columns that will break df into chunks for estimation (i.e., location, etc.). The default is normally correct and includes all columns except for date_column and case_column.

cases_column

character(1) the column in df that includes the case counts of interest.

date_column

character(1) the column in df that includes the date information about when cases reported.

...

passed on to estimate_Rt

Value

A "stacked" data.frame with the outputs from the R(t) estimation process and associated location information. The actual columns returned for the R(t) estimate will depend on the estimation_family parameter as well as other parameters specific to each method.

Author(s)

Sean Davis seandavi@gmail.com

See Also

Other analysis: estimate_Rt()

Other case-tracking: align_to_baseline(), beoutbreakprepared_data(), combined_us_cases_data(), coronadatascraper_data(), covidtracker_data(), ecdc_data(), estimate_Rt(), jhu_data(), nytimes_county_data(), owid_data(), plot_epicurve(), test_and_trace_data(), usa_facts_data(), who_cases()

Examples

library(dplyr)
nyt = nytimes_state_data() %>% 
    dplyr::filter(subset=='confirmed') %>%
    dplyr::arrange(state,date)
head(nyt)

# this may produce warnings, but the processing
# will still be correct....
res = bulk_estimate_Rt(head(nyt,500), 
    estimation_family='epiestim',method = 'parametric_si',
    config = list(mean_si=3.96, std_si=4.75))
head(res)
colnames(res)

library(ggplot2)
ggplot(res, aes(x=date_start,y=1/`Mean(R)`,color=state)) + 
    geom_smooth(se=FALSE) + ylim(c(0,1.5))


seandavi/sars2pack documentation built on May 13, 2022, 3:41 p.m.