## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----cic-example-------------------------------------------------------------- library(sccic) # Load workers' comp data if (requireNamespace("wooldridge", quietly = TRUE)) { data("injury", package = "wooldridge") y_00 <- injury$ldurat[injury$highearn == 0 & injury$afchnge == 0] y_01 <- injury$ldurat[injury$highearn == 0 & injury$afchnge == 1] y_10 <- injury$ldurat[injury$highearn == 1 & injury$afchnge == 0] y_11 <- injury$ldurat[injury$highearn == 1 & injury$afchnge == 1] # Continuous CIC (Theorem 3.1) result <- cic(y_00, y_01, y_10, y_11) print(result) # Discrete CIC (Theorem 4.1) — matches Athey and Imbens (2006) result_d <- cic(y_00, y_01, y_10, y_11, discrete = TRUE, boot = FALSE) print(result_d) } ## ----sccic-example, warning=FALSE--------------------------------------------- if (requireNamespace("Synth", quietly = TRUE)) { data("basque", package = "Synth") # Reshape to wide format gdp <- reshape(basque[, c("regionno", "year", "gdpcap")], idvar = "year", timevar = "regionno", direction = "wide") y_treated <- gdp[, "gdpcap.17"] # Basque Country donor_cols <- grep("gdpcap\\.", names(gdp), value = TRUE) donor_cols <- donor_cols[!donor_cols %in% c("gdpcap.17", "gdpcap.1")] donors <- as.matrix(gdp[, donor_cols]) valid <- complete.cases(y_treated, donors) result2 <- sc_cic(y_treated[valid], donors[valid, ], treatment_period = 16, seed = 42) print(result2) } ## ----boot-example, eval = FALSE----------------------------------------------- # result <- cic(y_00, y_01, y_10, y_11, boot = TRUE, boot_iters = 500, seed = 42)