test_that("cic returns correct structure", { set.seed(1) y_00 <- rnorm(100, 0, 1) y_01 <- rnorm(100, 0.5, 1) y_10 <- rnorm(50, 1, 1) y_11 <- rnorm(50, 2, 1) result <- cic(y_00, y_01, y_10, y_11) expect_s3_class(result, "cic") expect_true(!is.na(result$tau)) expect_true(!is.na(result$se)) expect_true(!is.na(result$pval)) expect_equal(result$N, 300) }) test_that("cic matches qte::CiC on workers comp data", { skip_if_not_installed("wooldridge") data("injury", package = "wooldridge") result <- cic( 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] ) # Known result from validation: tau = 0.0687 expect_equal(round(result$tau, 2), 0.07, tolerance = 0.01) }) test_that("cic with no treatment returns near-zero effect", { set.seed(42) y_00 <- rnorm(200, 0, 1) y_01 <- rnorm(200, 1, 1) # time trend y_10 <- rnorm(200, 0, 1) # same as control pre y_11 <- rnorm(200, 1, 1) # same time trend, no treatment result <- cic(y_00, y_01, y_10, y_11) # With no treatment, tau should be near zero expect_lt(abs(result$tau), 0.5) }) test_that("bootstrap SE is computed when requested", { set.seed(1) y_00 <- rnorm(50); y_01 <- rnorm(50) y_10 <- rnorm(30); y_11 <- rnorm(30) result <- cic(y_00, y_01, y_10, y_11, boot = TRUE, boot_iters = 100, seed = 42) expect_true(!is.na(result$boot_se)) expect_gt(result$boot_se, 0) })