Skip to contents

Estimates the canonical single-interruption segmented regression $$Y_t = \beta_0 + \beta_1 t + \beta_2 D_t + \beta_3 (t - t_0) D_t + \varepsilon_t$$ where \(D_t\) switches on at the interruption. \(\beta_2\) is the immediate level change and \(\beta_3\) the slope change. Inference uses native Newey-West (Bartlett-kernel) HAC standard errors to respect serial correlation.

Usage

morie_its(
  data,
  outcome,
  time,
  interruption_time,
  covariates = NULL,
  lag = NULL,
  alpha = 0.05
)

Arguments

data

Data frame ordered by (or containing) the time index.

outcome

Outcome column name.

time

Time column name (numeric).

interruption_time

First period of the intervention.

covariates

Optional covariate column names.

lag

HAC lag; default is the Newey-West rule of thumb.

alpha

Significance level.

Value

A list with level_change, slope_change (each a list with estimate/std_error/ci/p_value), coefficients, counterfactual (data frame with observed, fitted, and no-intervention paths), n_pre, n_post, method.

References

Bernal, J. L., Cummins, S., & Gasparrini, A. (2017). Interrupted time series regression for the evaluation of public health interventions. IJE, 46(1), 348–355.

Examples

df <- data.frame(t = 1:60,
                 y = 10 + 0.2 * (1:60) + ifelse(1:60 >= 40, 5, 0) +
                   rnorm(60))
fit <- morie_its(df, "y", "t", interruption_time = 40)
fit$level_change$estimate
#> [1] 4.958968