Learn R Programming

staggR (version 0.1.1)

ave_coeff: Aggregate a specified set of terms and corresponding standard errors from an sdid model object

Description

Aggregate a specified set of terms and corresponding standard errors from an sdid model object

Usage

ave_coeff(sdid, coefs)

Value

data.frame

Arguments

sdid

sdid object containing the model to summarize

coefs

Character vector containing the names of coefficients to aggregate. Can be specified using select_period() or select_terms().

Examples

Run this code
# First fit a model to generate a sdid object
sdid_hosp <- sdid(hospitalized ~ cohort + yr + age + sex + comorb,
                  df = hosp,
                  intervention_var  = "intervention_yr")

# Then request an average of a specified set of coefficients. Here we use the
# select_period() convenience function to automatically select all
# coefficients representing the post-intervention period.
ave_coeff(sdid_hosp, coefs = select_period(sdid_hosp, period = "post"))

# We could also specify the coefficients manually. Here we request the
# average effect for Cohort 5 in the post-intervention period.
ave_coeff(sdid_hosp, coefs = c("cohort_5:yr_2015", "cohort_5:yr_2016",
                               "cohort_5:yr_2017", "cohort_5:yr_2018",
                               "cohort_5:yr_2019", "cohort_5:yr_2020"))

Run the code above in your browser using DataLab