detrend: Adjust outcomes for differential trends

View source: R/detrend.R

detrendR Documentation

Adjust outcomes for differential trends

Description

Adjust outcomes for differential trends

Usage

detrend(sdid, df)

Arguments

sdid

sdid object containing the model to summarize.

df

A data frame containing the variables in the model.

Value

data.frame

Examples

# First fit a model using the original outcome, with or without covariate adjustments.
sdid_hosp <- sdid(hospitalized ~ cohort + yr + age + sex + comorb,
                  df = hosp,
                  intervention_var  = "intervention_yr")

# Calculate de-trending adjustments
hosp_det <- detrend(sdid = sdid_hosp,
                    df = hosp)

# Then refit the same model, substituting the _detrended version of the outcome
sdid_hosp_det <- sdid(hospitalized_detrended ~ cohort + yr + age + sex + comorb,
                      df = hosp_det,
                      intervention_var = "intervention_yr")

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