plot_cits_result: CITS Automatic Analysis and Visualization

View source: R/cits_plot.R

plot_cits_resultR Documentation

CITS Automatic Analysis and Visualization

Description

Visualizes the results of a controlled interrupted time series (CITS) model fitted using 'cits()'. The function plots observed data points, fitted values, and 95

Usage

plot_cits_result(
  res,
  y_col = "y",
  T_col = "T",
  E_col = "E",
  intervention_time = NULL
)

Arguments

res

A list returned by 'cits()', containing model output and fitted values.

y_col

Name of the outcome variable (string). Corresponds to 'y' in 'cits()'.

T_col

Name of the time index variable (string). Corresponds to 'T' in 'cits()'.

E_col

Name of the group indicator variable (string). Corresponds to 'E' in 'cits()'.

intervention_time

Optional numeric. If provided, a vertical dashed line is drawn at this time to mark the intervention point.

Value

A ggplot object showing observed points, fitted lines, confidence ribbons, and (optionally) the intervention line.

Examples

# Synthetic example
df <- data.frame(
  T = 1:100,
  E = rep(c(0,1), each = 100),
  I = c(rep(0,50), rep(1,50), rep(0,50), rep(1,50)),
  y = rnorm(200)
)

# Use lightweight ARMA search for examples (CRAN speed requirement)
res <- cits(
  df,
  y_col = "y",
  T_col = "T",
  I_col = "I",
  E_col = "E",
  p_range = 0:1,
  q_range = 0:0
)

plot_cits_result(res)


citsr documentation built on July 12, 2026, 5:07 p.m.