The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

citsr Package Examples

Hanmin Gu

2025-12-17

Overview

This vignette demonstrates how to use the citsr package for conducting Controlled Interrupted Time Series (CITS) analysis. The package provides functions for model fitting using generalized least squares (GLS), visualizing fitted trajectories with confidence intervals, and generating counterfactual predictions for treatment groups.

1. Example Data

The package includes a built-in simulated dataset named df_cits_example.

data("df_cits_example", package = "citsr")
head(df_cits_example)

C:368029e7d2d_examples.R

2. Fit CITS Model

res <- cits(
  data = df_cits_example,
  y_col = "y",
  T_col = "T",
  I_col = "I",
  E_col = "E"
)

summary(res$model)

C:368029e7d2d_examples.R

3. Visualize Fitted Values with 95% Confidence Intervals

plot_fitted <- plot_cits_result(
  res,
  y_col = "y",
  T_col = "T",
  E_col = "E"
)
plot_fitted

C:368029e7d2d_examples.R

4. Visualize Counterfactual Trajectory for Treatment Group

plot_cf <- plot_cits_result_cf(
  res,
  y_col = "y",
  T_col = "T",
  I_col = "I",
  E_col = "E",
  intervention_time = 50
)
plot_cf

C:368029e7d2d_examples.R

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.