View source: R/select_period.R
| select_period | R Documentation |
Retrieve a list of interaction terms from a sdid model representing the pre-intervention period
select_period(sdid, period = "post", cohorts = NULL)
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 |
character vector
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.