---
title: "Controlled Interrupted Time Series (CITS) Methodology"
author: "Hanmin Gu"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{CITS Methodology Overview}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

# Overview

This vignette provides an overview of the Controlled Interrupted Time Series (CITS) methodology, explaining its analytic principles, model structure, and workflow.  
CITS extends the standard Interrupted Time Series (ITS) framework by introducing a comparison (control) group that did not receive the intervention, improving causal interpretation.

# 1. Purpose

CITS evaluates how an intervention affects an outcome variable over time by comparing trends between a treatment group and a control group.  
Unlike a single‐group ITS model, the CITS design helps adjust for external shocks or secular trends through the inclusion of a parallel control series.

# 2. Data Structure

A typical CITS dataset includes:

- **y**: Outcome variable  
- **T**: Time index  
- **I**: Intervention indicator (0 = before intervention, 1 = after intervention)  
- **E**: Group indicator (0 = control, 1 = treatment)

# 3. Basic Model

The canonical CITS specification is:

$$
y_{it} = \beta_0 + \beta_1 T_t + \beta_2 I_t + \beta_3 E_i +
\beta_4 (T \times I)_t +
\beta_5 (E \times T)_{it} +
\beta_6 (E \times I)_{it} +
\beta_7 (E \times T \times I)_{it} +
\varepsilon_{it}
$$

Where:

- \( \beta_1 \): baseline trend  
- \( \beta_2 \): immediate intervention effect (control group)  
- \( \beta_3 \): baseline level difference (treatment vs control)  
- \( \beta_4 \): post-intervention trend change (control group)  
- \( \beta_5 \): treatment–control trend difference before intervention  
- \( \beta_6 \): treatment–control level difference at intervention  
- \( \beta_7 \): post-intervention trend difference (treatment vs control)  

The error term \( \varepsilon_{it} \) may exhibit temporal autocorrelation.  
The **citsr** package addresses this by fitting the model using **generalized least squares (GLS)** with optional **ARMA(p,q)** correlation structures.

### ARMA Handling

The `cits()` function:

1. Searches candidate ARMA(p,q) models over a user-specified range  
2. Selects the structure minimizing AIC  
3. If all ARMA fits fail, automatically falls back to standard GLS  

# 4. Analysis Workflow

1. **Data preparation**  
   Construct variables \( y, T, I, E \) and their interaction terms.  
   (The `cits()` function creates interactions automatically if not provided.)

2. **Model fitting**  
   Estimate the CITS model using GLS or ARMA‐GLS via the `cits()` function.

3. **Intervention effect estimation**  
   Coefficients \( \beta_2, \beta_4, \beta_6, \beta_7 \) describe level and trend changes attributable to the intervention.

4. **Counterfactual prediction**  
   Counterfactual trajectories for the treatment group are generated by setting  
   \( I = 0 \) after the intervention time and recomputing relevant interaction terms.
   This enables comparison of *actual* vs. *no‐intervention* outcomes.

# 5. Advantages

- Controls for unobserved external shocks using a comparison group  
- Captures both level and slope changes before and after intervention  
- Supports autocorrelation modeling through GLS and ARMA structures  
- Provides interpretable counterfactual predictions

# 6. Considerations

- Sufficient pre/post intervention observations are essential  
- Parallel trends assumption between groups should be evaluated  
- Additional covariates may be necessary in applied contexts  
- Autocorrelation should be tested and accounted for when present  

# References

Linden, A., & Adams, J. L. (2011). *Applying a propensity score–based weighting model to interrupted time series data: Improving causal inference in program evaluation.* Journal of Evaluation in Clinical Practice, 17(6), 1231–1238. <doi:10.1111/j.1365-2753.2010.01504.x>

Lopez Bernal, J., Cummins, S., & Gasparrini, A. (2018). *Use of controls in interrupted time series studies of public health interventions.* International Journal of Epidemiology, 47(6), 2082–2093. <doi:10.1093/ije/dyy135>
