Learn R Programming

staggR (version 0.1.1)

id_tsi: 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)

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.

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.

Examples

Run this code
# 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")

Run the code above in your browser using DataLab