id_tsi: Identify time-since-intervention

View source: R/id_tsi.R

id_tsiR Documentation

Identify time-since-intervention

Description

id_tsi() identifies the number of time periods relative to the intervention for each observation. This information is used for plotting and for aggregating model coefficients with ave_coeff().

Usage

id_tsi(df, cohort_var, time_var, intervention_var)

Arguments

df

Data frame containing the variables in the model.

cohort_var

Name of the variable in df that contains cohort assignments.

time_var

Name of the variable in df that contains time periods.

intervention_var

Name of the cohort-level variable in df that specifies which values in time_var correspond to the first post-intervention time period for each cohort.

Value

tsi Object containing a data frame showing time since intervention for each time period in the data frame for each cohort in the data frame.

Examples

# Generate a tsi object, containing a data frame showing the time since
# intervention (TSI value) for each time period in the data frame for each
# cohort.
id_tsi(hosp,
       cohort_var = "cohort",
       time_var = "yr",
       intervention_var = "intervention_yr")

staggR documentation built on April 2, 2026, 5:08 p.m.