Learn R Programming

staggR (version 0.1.1)

select_period: Retrieve a list of interaction terms from a sdid model representing the pre-intervention period

Description

Retrieve a list of interaction terms from a sdid model representing the pre-intervention period

Usage

select_period(sdid, period = "post", cohorts = NULL)

Value

character vector

Arguments

sdid

A sdid object

period

One of 'pre' or 'post', to return the pre-intervention or post-intervention coefficients respectively

cohorts

A character vector containing cohort levels to include in the term selection. If cohorts is omitted, all available cohorts will be selected

Examples

Run this code
# Fit a staggered difference-in-differences model
sdid_hosp <- sdid(hospitalized ~ cohort + yr + age + sex + comorb,
                  df = hosp,
                  intervention_var  = "intervention_yr")

# Select coefficients corresponding to the PRE-intervention period for cohort 5
coef_selection_pre <- select_period(sdid_hosp,
                                period = "pre",
                                cohorts = "5")
coef_selection_pre

# Pass the set of coefficients to `ave_coeff` to aggregate the effect of the
# intervention
ave_coeff(sdid_hosp, coefs = coef_selection_pre)

# Select coefficients corresponding to the POST-intervention period for cohort 5
coef_selection_post <- select_period(sdid_hosp,
                                     period = "post",
                                     cohorts = "5")
coef_selection_post

# Pass the set of coefficients to `ave_coeff` to aggregate the effect of the
# intervention
ave_coeff(sdid_hosp, coefs = coef_selection_post)

Run the code above in your browser using DataLab