* using log directory ‘/data/localhost/ripley/R/packages/tests-MKL/clusterIV.Rcheck’ * using R Under development (unstable) (2026-11-20 r90940) * using platform: x86_64-pc-linux-gnu * R was compiled by gcc (GCC) 16.2.1 20261029 (Red Hat 16.2.1-3) GNU Fortran (GCC) 16.2.1 20261029 (Red Hat 16.2.1-3) * running under: Fedora Linux 44 (Server Edition) * using session charset: UTF-8 * current time: 2026-11-21 00:18:49 UTC * using option ‘--no-stop-on-test-error’ * checking for file ‘clusterIV/DESCRIPTION’ ... OK * this is package ‘clusterIV’ version ‘0.2.0’ * package encoding: UTF-8 * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for executable files ... OK * checking for hidden files and directories ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking whether package ‘clusterIV’ can be installed ... OK * checking package directory ... OK * checking ‘build’ directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking code files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the package can be unloaded cleanly ... OK * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking whether startup messages can be suppressed ... OK * checking use of S3 registration ... OK * checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... [10s/11s] OK * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking installed files from ‘inst/doc’ ... OK * checking files in ‘vignettes’ ... OK * checking examples ... OK * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... Running ‘test-api-safety.R’ Running ‘test-api.R’ Running ‘test-cjar.R’ Running ‘test-cjive.R’ Running ‘test-cjscore.R’ Running ‘test-crossfit.R’ Running ‘test-effF.R’ Running ‘test-hdfe-safety.R’ Running ‘test-input-space.R’ Running ‘test-inversion-safety.R’ Running ‘test-kernel-whitened.R’ Running ‘test-output.R’ [23s/25s] ERROR Running the tests in ‘tests/test-api.R’ failed. Complete output: > # API-coherence tests (base R, no testthat), in the style of test-cjive.R: > # each block stops with an informative message on failure, so a failure fails > # `R CMD check`. Covers the WP2 gates: formula-dialect equivalence (G2), the > # grouping-factor fix (G3), subset/na.action (G4), and iv_infer() consistency > # with the standalone calls plus single-fire advisories (G5). > > library(clusterIV) > > ok <- function(cond, msg) { + if (!isTRUE(cond)) stop("FAILED: ", msg, call. = FALSE) + cat("PASS:", msg, "\n") + } > errs_with <- function(expr, pattern) { + msg <- tryCatch({ expr; NULL }, error = function(e) conditionMessage(e)) + is.character(msg) && grepl(pattern, msg) + } > > # Compare two fitted objects field by field at `tol`, skipping `call`. > # Numeric fields must match elementwise, treating NA == NA and matching > # infinities as equal; everything else must be identical(). > fields_equal <- function(a, b, tol = 1e-12, skip = "call") { + nms <- union(names(a), names(b)) + for (nm in setdiff(nms, skip)) { + va <- a[[nm]]; vb <- b[[nm]] + if (is.numeric(va) && is.numeric(vb)) { + if (length(va) != length(vb)) return(nm) + same <- (is.na(va) & is.na(vb)) | + (is.infinite(va) & is.infinite(vb) & sign(va) == sign(vb)) | + (!is.na(va) & !is.na(vb) & is.finite(va) & is.finite(vb) & + abs(va - vb) < tol) + if (!all(same)) return(nm) + } else if (!identical(va, vb)) { + return(nm) + } + } + TRUE + } > ok_fields <- function(a, b, msg, tol = 1e-12, skip = "call") { + r <- fields_equal(a, b, tol = tol, skip = skip) + if (!isTRUE(r)) stop("FAILED: ", msg, " (field: ", r, ")", call. = FALSE) + cat("PASS:", msg, "\n") + } > > quiet <- function(expr) suppressWarnings(expr) > > # --- a design with controls, fixed effects and a judge factor --------------- > set.seed(2026) > G <- 25L > sizes <- sample(5:12, G, replace = TRUE) > n <- sum(sizes) > cl <- rep(seq_len(G), sizes) > judge <- factor(sample(paste0("j", 1:7), n, replace = TRUE)) > fe1 <- factor(sample(letters[1:9], n, replace = TRUE)) > w1 <- rnorm(n); w2 <- rnorm(n) > u <- rnorm(G)[cl] > x <- 0.7 * as.numeric(judge) + 0.3 * w1 + u + rnorm(n) > y <- 0.5 * x + 0.4 * w1 - 0.2 * w2 + u + rnorm(n) > wt <- runif(n, 0.5, 2) > dat <- data.frame(y = y, x = x, judge = judge, fe1 = fe1, + w1 = w1, w2 = w2, cl = cl, wt = wt) > > # === G2: dialect equivalence ================================================= > # Vector interface, legacy formula (controls via the argument) and fixest > # formula (controls inside the formula) must agree on every returned field. > for (fn in list(list(f = cjive, tag = "cjive"), + list(f = cjar, tag = "cjar"), + list(f = cjscore, tag = "cjscore"), + list(f = iv_infer, tag = "iv_infer"))) { + f <- fn$f + vec <- quiet(f(y, x, judge, cluster = cl, controls = cbind(w1, w2), + fixed_effects = fe1)) + leg <- quiet(f(y ~ x | judge | fe1, data = dat, cluster = cl, + controls = ~ w1 + w2)) + fxs <- quiet(f(y ~ w1 + w2 | fe1 | x ~ judge, data = dat, cluster = cl)) + if (fn$tag == "iv_infer") { + for (part in c("cjive", "cjar", "cjscore")) { + ok_fields(vec[[part]], leg[[part]], + sprintf("[G2 %s$%s] legacy formula == vector (1e-12, all fields)", + fn$tag, part)) + ok_fields(vec[[part]], fxs[[part]], + sprintf("[G2 %s$%s] fixest formula == vector (1e-12, all fields)", + fn$tag, part)) + } + ok_fields(vec, leg, "[G2 iv_infer] legacy formula == vector (shared fields)", + skip = c("call", "cjive", "cjar", "cjscore")) + ok_fields(vec, fxs, "[G2 iv_infer] fixest formula == vector (shared fields)", + skip = c("call", "cjive", "cjar", "cjscore")) + } else { + ok_fields(vec, leg, + sprintf("[G2 %s] legacy formula == vector (1e-12, all fields)", fn$tag)) + ok_fields(vec, fxs, + sprintf("[G2 %s] fixest formula == vector (1e-12, all fields)", fn$tag)) + } + } PASS: [G2 cjive] legacy formula == vector (1e-12, all fields) PASS: [G2 cjive] fixest formula == vector (1e-12, all fields) PASS: [G2 cjar] legacy formula == vector (1e-12, all fields) PASS: [G2 cjar] fixest formula == vector (1e-12, all fields) PASS: [G2 cjscore] legacy formula == vector (1e-12, all fields) PASS: [G2 cjscore] fixest formula == vector (1e-12, all fields) PASS: [G2 iv_infer$cjive] legacy formula == vector (1e-12, all fields) PASS: [G2 iv_infer$cjive] fixest formula == vector (1e-12, all fields) PASS: [G2 iv_infer$cjar] legacy formula == vector (1e-12, all fields) PASS: [G2 iv_infer$cjar] fixest formula == vector (1e-12, all fields) PASS: [G2 iv_infer$cjscore] legacy formula == vector (1e-12, all fields) PASS: [G2 iv_infer$cjscore] fixest formula == vector (1e-12, all fields) PASS: [G2 iv_infer] legacy formula == vector (shared fields) PASS: [G2 iv_infer] fixest formula == vector (shared fields) > > # iv_compare through the same three routes (a data frame, compared column-wise). > tab_v <- quiet(iv_compare(y, x, judge, cluster = cl, controls = cbind(w1, w2), + fixed_effects = fe1)) > tab_l <- quiet(iv_compare(y ~ x | judge | fe1, data = dat, cluster = cl, + controls = ~ w1 + w2)) > tab_f <- quiet(iv_compare(y ~ w1 + w2 | fe1 | x ~ judge, data = dat, cluster = cl)) > num <- vapply(tab_v, is.numeric, logical(1)) > ok(identical(tab_v$estimator, tab_l$estimator) && + identical(tab_v$estimator, tab_f$estimator) && + max(abs(as.matrix(tab_v[, num]) - as.matrix(tab_l[, num]))) < 1e-12 && + max(abs(as.matrix(tab_v[, num]) - as.matrix(tab_f[, num]))) < 1e-12, + "[G2 iv_compare] all three routes agree (1e-12)") PASS: [G2 iv_compare] all three routes agree (1e-12) > > # The fixest exog codes: 1 = intercept only, 0 = no intercept. > fx1 <- quiet(cjive(y ~ 1 | x ~ judge, data = dat, cluster = cl)) > v1 <- quiet(cjive(y, x, judge, cluster = cl)) > ok_fields(v1, fx1, "[G2] fixest exog = 1 == intercept-only vector call") PASS: [G2] fixest exog = 1 == intercept-only vector call > fx0 <- quiet(cjive(y ~ 0 | x ~ judge, data = dat, cluster = cl)) > v0 <- quiet(cjive(y, x, judge, cluster = cl, intercept = FALSE)) > ok_fields(v0, fx0, "[G2] fixest exog = 0 == intercept = FALSE vector call") PASS: [G2] fixest exog = 0 == intercept = FALSE vector call > > # Every FE span contains the intercept. A grouping instrument must therefore > # remain reference-coded when FE are present even if intercept = FALSE; full > # coding would be singular after absorption. Pin the shared vector engine, > # the formula route, every fitted public API, and the raw nuisance count. > Zref_fe0 <- model.matrix(~ judge)[, -1L, drop = FALSE] > for (fn in list(list(f = cjive, tag = "cjive"), + list(f = cjar, tag = "cjar"), + list(f = cjscore, tag = "cjscore"))) { + fac <- quiet(fn$f(y, x, judge, cluster = cl, fixed_effects = fe1, + intercept = FALSE)) + ref <- quiet(fn$f(y, x, Zref_fe0, cluster = cl, fixed_effects = fe1, + intercept = FALSE)) + ok_fields(fac, ref, + sprintf("[G2 %s] FE + intercept=FALSE factor z uses reference coding", + fn$tag)) + ok(fac$k == ncol(Zref_fe0) && fac$k_controls == nlevels(fe1), + sprintf("[G2 %s] FE factor-z k and nuisance count are non-redundant", + fn$tag)) + } PASS: [G2 cjive] FE + intercept=FALSE factor z uses reference coding PASS: [G2 cjive] FE factor-z k and nuisance count are non-redundant PASS: [G2 cjar] FE + intercept=FALSE factor z uses reference coding PASS: [G2 cjar] FE factor-z k and nuisance count are non-redundant PASS: [G2 cjscore] FE + intercept=FALSE factor z uses reference coding PASS: [G2 cjscore] FE factor-z k and nuisance count are non-redundant > > wf_fac <- quiet(iv_infer(y, x, judge, cluster = cl, fixed_effects = fe1, + intercept = FALSE)) > wf_ref <- quiet(iv_infer(y, x, Zref_fe0, cluster = cl, fixed_effects = fe1, + intercept = FALSE)) > for (part in c("cjive", "cjar", "cjscore")) { + ok_fields(wf_fac[[part]], wf_ref[[part]], + sprintf("[G2 iv_infer$%s] FE factor-z reference coding", part)) + } PASS: [G2 iv_infer$cjive] FE factor-z reference coding PASS: [G2 iv_infer$cjar] FE factor-z reference coding PASS: [G2 iv_infer$cjscore] FE factor-z reference coding > ok(wf_fac$k == ncol(Zref_fe0) && wf_fac$k_controls == nlevels(fe1), + "[G2 iv_infer] FE factor-z k and nuisance count are non-redundant") PASS: [G2 iv_infer] FE factor-z k and nuisance count are non-redundant > > tab_fac <- quiet(iv_compare(y, x, judge, cluster = cl, + fixed_effects = fe1, intercept = FALSE)) > tab_ref <- quiet(iv_compare(y, x, Zref_fe0, cluster = cl, + fixed_effects = fe1, intercept = FALSE)) > num_fe0 <- vapply(tab_fac, is.numeric, logical(1)) > ok(identical(tab_fac$estimator, tab_ref$estimator) && + max(abs(as.matrix(tab_fac[, num_fe0]) - + as.matrix(tab_ref[, num_fe0]))) < 1e-12, + "[G2 iv_compare] FE + intercept=FALSE factor z uses reference coding") PASS: [G2 iv_compare] FE + intercept=FALSE factor z uses reference coding > > fx_fe0 <- quiet(cjive(y ~ 0 | fe1 | x ~ judge, data = dat, cluster = cl)) > ok_fields(fx_fe0, + quiet(cjive(y, x, judge, cluster = cl, fixed_effects = fe1, + intercept = FALSE)), + "[G2 formula] FE + intercept=FALSE factor z equals vector route") PASS: [G2 formula] FE + intercept=FALSE factor z equals vector route > > # === G3: the grouping factor survives the formula path ====================== > lm_vec <- cjive(y, x, judge, cluster = cl, method = "leaveout_mean") > lm_leg <- cjive(y ~ x | judge, data = dat, cluster = cl, + method = "leaveout_mean") > lm_fxs <- cjive(y ~ 1 | x ~ judge, data = dat, cluster = cl, + method = "leaveout_mean") > ok_fields(lm_vec, lm_leg, "[G3] leaveout_mean via legacy formula == vector") PASS: [G3] leaveout_mean via legacy formula == vector > ok_fields(lm_vec, lm_fxs, "[G3] leaveout_mean via fixest formula == vector") PASS: [G3] leaveout_mean via fixest formula == vector > > # A judge confined to one cluster remains legal for the dense encoded-dummy > # path when the actual leave-out Gram is full rank, but the group-mean shortcut > # is undefined. That stricter requirement must survive both formula dialects. > jud_bad <- as.character(judge) > jud_bad[cl == 1L] <- "solo" > jud_bad[cl != 1L & jud_bad == "solo"] <- "j1" > dat_bad <- transform(dat, judge = factor(jud_bad)) > ok(errs_with(cjive(y ~ x | judge, data = dat_bad, cluster = cl, + method = "leaveout_mean"), + "entirely in one cluster"), + "[G3] single-cluster judge: leaveout_mean error via legacy formula") PASS: [G3] single-cluster judge: leaveout_mean error via legacy formula > ok(errs_with(cjive(y ~ 1 | x ~ judge, data = dat_bad, cluster = cl, + method = "leaveout_mean"), + "entirely in one cluster"), + "[G3] single-cluster judge: leaveout_mean error via fixest formula") PASS: [G3] single-cluster judge: leaveout_mean error via fixest formula > > # === G4: subset and na.action ================================================ > # NAs scattered across y, a control, the cluster id and the weight vector. > dat_na <- dat > dat_na$y[c(4L, 40L)] <- NA > dat_na$w1[15L] <- NA > dat_na$cl[27L] <- NA > dat_na$wt[c(33L, 90L)] <- NA > keep <- stats::complete.cases(dat_na$y, dat_na$w1, dat_na$cl, dat_na$wt) > > for (fn in list(list(f = cjive, tag = "cjive"), + list(f = cjar, tag = "cjar"), + list(f = cjscore, tag = "cjscore"))) { + f <- fn$f + fit_na <- quiet(f(y ~ x | judge, data = dat_na, cluster = cl, + controls = ~ w1, weights = wt)) + fit_man <- quiet(f(dat_na$y[keep], x[keep], droplevels(judge[keep]), + cluster = dat$cl[keep], + controls = cbind(w1 = dat_na$w1[keep]), + weights = dat$wt[keep])) + ok_fields(fit_na, fit_man, + sprintf("[G4 %s] na.omit formula == vector on filtered data (1e-12)", + fn$tag), + skip = c("call", "n_dropped")) + ok(fit_na$n_dropped == sum(!keep), + sprintf("[G4 %s] n_dropped == %d", fn$tag, sum(!keep))) + out <- capture.output(print(fit_na)) + ok(any(grepl("dropped due to missing values", out)), + sprintf("[G4 %s] the drop is reported by print()", fn$tag)) + } PASS: [G4 cjive] na.omit formula == vector on filtered data (1e-12) PASS: [G4 cjive] n_dropped == 6 PASS: [G4 cjive] the drop is reported by print() PASS: [G4 cjar] na.omit formula == vector on filtered data (1e-12) PASS: [G4 cjar] n_dropped == 6 PASS: [G4 cjar] the drop is reported by print() Error: FAILED: [G4 cjscore] na.omit formula == vector on filtered data (1e-12) (field: coef_var) Execution halted * checking for unstated dependencies in vignettes ... OK * checking package vignettes ... OK * checking re-building of vignette outputs ... [10s/11s] OK * checking PDF version of manual ... OK * checking HTML version of manual ... OK * checking for non-standard things in the check directory ... OK * checking for detritus in the temp directory ... OK * DONE Status: 1 ERROR See ‘/data/localhost/ripley/R/packages/tests-MKL/clusterIV.Rcheck/00check.log’ for details. Command exited with non-zero status 1 Time 1:16.97, 63.26 + 6.74