| Title: | Clustered Jackknife Instrumental Variables Estimation |
|---|---|
| Description: | Tools for instrumental variables estimation and inference under clustered errors with many instruments. The current release provides the cluster-jackknife IV estimator (CJIVE) of Frandsen, Leslie and McIntyre (2025) <doi:10.1162/rest.a.263> for a single endogenous regressor in a just-identified design, with cluster-robust inference: each observation's first-stage value is fitted leaving out its entire cluster, which removes the many-instrument bias that survives clustering. The leave-cluster-out fits use an exact Woodbury block update -- one factorisation of the instrument Gram matrix plus a small solve per cluster -- so the estimator scales to large samples. A companion 'iv_compare()' reports ordinary least squares, two-stage least squares, the observation-level jackknife and CJIVE on a common cluster-robust standard error. |
| Authors: | Atal Katawazi [aut, cre] |
| Maintainer: | Atal Katawazi <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-06-30 16:48:50 UTC |
| Source: | https://github.com/cran/clusterIV |
Computes the cluster-jackknife IV estimator of Frandsen, Leslie and McIntyre (2025) for a single endogenous regressor in a just-identified design, with cluster-robust inference. The first-stage value for each observation is fitted from a regression that leaves out the observation's entire cluster, which removes the many-instrument bias that survives clustering.
cjive(y, ...) ## Default S3 method: cjive( y, x, z, cluster, controls = NULL, weights = NULL, level = 0.95, intercept = TRUE, method = c("auto", "dense", "leaveout_mean"), ... ) ## S3 method for class 'formula' cjive( formula, data, cluster, controls = NULL, weights = NULL, level = 0.95, intercept = TRUE, method = c("auto", "dense", "leaveout_mean"), ... ) ## S3 method for class 'cjive' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'cjive' summary(object, ...) ## S3 method for class 'summary.cjive' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'cjive' coef(object, ...) ## S3 method for class 'cjive' vcov(object, ...) ## S3 method for class 'cjive' confint(object, parm, level = 0.95, ...)cjive(y, ...) ## Default S3 method: cjive( y, x, z, cluster, controls = NULL, weights = NULL, level = 0.95, intercept = TRUE, method = c("auto", "dense", "leaveout_mean"), ... ) ## S3 method for class 'formula' cjive( formula, data, cluster, controls = NULL, weights = NULL, level = 0.95, intercept = TRUE, method = c("auto", "dense", "leaveout_mean"), ... ) ## S3 method for class 'cjive' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'cjive' summary(object, ...) ## S3 method for class 'summary.cjive' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'cjive' coef(object, ...) ## S3 method for class 'cjive' vcov(object, ...) ## S3 method for class 'cjive' confint(object, parm, level = 0.95, ...)
y |
Outcome (numeric vector), or a two-sided formula |
... |
Unused. |
x |
Single endogenous regressor (numeric vector); or, for the
|
z |
Instruments: a numeric vector/matrix, or a factor/character grouping vector for a judge design (expanded internally to a dummy design with one reference level dropped, the intercept supplying the rest). |
cluster |
Cluster identifiers (length n). For the formula method a
one-sided formula ( |
controls |
Optional covariates (FLM's |
weights |
Optional strictly positive precision weights. |
level |
Confidence level for the reported interval. |
intercept |
Logical; partial out an intercept (default |
method |
One of |
formula |
A formula |
data |
A data frame in which to evaluate the formula. |
object |
A fitted |
digits |
Number of significant digits to print. |
parm |
Ignored (a single coefficient is estimated). |
The estimator is the covariance ratio
with the
cluster-jackknife constructed instrument . Covariates are handled
by Frisch-Waugh-Lovell: , and each instrument are residualised
on the covariates (with an intercept) once, up front, then the estimator runs
on the residuals. This dense route is the single convention everywhere, so
cjive() and iv_compare return the identical CJIVE for any
design. The leave-cluster-out fits are computed by a Woodbury block update
(one Cholesky of plus a small solve per cluster), exact against the
brute-force definition, and collapsing to observation-level JIVE when every
cluster is a singleton.
An object of class "cjive": a list with coefficient,
se, statistic, p.value, conf.low,
conf.high, level, the diagnostics n, G, p,
path ("dense" or "leaveout_mean") and maxlev
(the maximum within-cluster leverage , a
conditioning diagnostic; NA on the mean path), and the call.
cjive(default): matrix/vector interface.
cjive(formula): formula interface y ~ x | z.
print(cjive): Print a concise summary of the fit.
summary(cjive): Build a summary object.
print(summary.cjive): Print method for the summary object.
coef(cjive): Extract the point estimate.
vcov(cjive): Extract the cluster-robust (co)variance.
confint(cjive): Confidence interval for the coefficient.
Frandsen, B., Leslie, E. and McIntyre, S. (2025). Cluster Jackknife Instrumental Variables Estimation. Review of Economics and Statistics.
set.seed(1) G <- 40; ng <- 6; n <- G * ng cl <- rep(seq_len(G), each = ng) j <- factor(rep(rep(1:4, length.out = ng), G)) # judge identity u <- rnorm(G)[cl] x <- as.numeric(j) + u + rnorm(n) y <- 1.5 * x + u + rnorm(n) fit <- cjive(y, x, j, cluster = cl) print(fit) ## formula interface dat <- data.frame(y = y, x = x, j = j, cl = cl) cjive(y ~ x | j, data = dat, cluster = ~cl)set.seed(1) G <- 40; ng <- 6; n <- G * ng cl <- rep(seq_len(G), each = ng) j <- factor(rep(rep(1:4, length.out = ng), G)) # judge identity u <- rnorm(G)[cl] x <- as.numeric(j) + u + rnorm(n) y <- 1.5 * x + u + rnorm(n) fit <- cjive(y, x, j, cluster = cl) print(fit) ## formula interface dat <- data.frame(y = y, x = x, j = j, cl = cl) cjive(y ~ x | j, data = dat, cluster = ~cl)
Returns OLS, 2SLS, JIVE and CJIVE for the same design, each reported with the identical just-identified cluster-robust IV sandwich standard error; only the constructed instrument differs between rows. This reproduces the shape of Table 1 in Frandsen, Leslie and McIntyre (2025).
iv_compare( y, x, z, cluster, controls = NULL, weights = NULL, level = 0.95, intercept = TRUE )iv_compare( y, x, z, cluster, controls = NULL, weights = NULL, level = 0.95, intercept = TRUE )
y |
Outcome (numeric vector). |
x |
Single endogenous regressor (numeric vector). |
z |
Instruments (numeric matrix/vector or a grouping factor). |
cluster |
Cluster identifiers (length n). For the formula method a
one-sided formula ( |
controls |
Optional covariates (FLM's |
weights |
Optional strictly positive precision weights. |
level |
Confidence level for the reported interval. |
intercept |
Logical; partial out an intercept (default |
The constructed instruments are: OLS, the residualised
itself; 2SLS, the full-sample fit ; JIVE, the leave-one-out
fit ; CJIVE, the leave-cluster-out block fit.
The CJIVE row equals cjive(..., method = "dense") on the same design.
A data frame with one row per estimator (in the order OLS, 2SLS,
JIVE, CJIVE) and columns estimator, coefficient, se,
statistic, p.value, conf.low, conf.high.
Frandsen, B., Leslie, E. and McIntyre, S. (2025). Cluster Jackknife Instrumental Variables Estimation. Review of Economics and Statistics.
set.seed(2) G <- 50; ng <- 5; n <- G * ng cl <- rep(seq_len(G), each = ng) z <- matrix(rnorm(n * 3), n, 3) u <- rnorm(G)[cl] x <- z %*% c(1, -1, 0.5) + u + rnorm(n) y <- 2 * x + u + rnorm(n) iv_compare(y, x, z, cluster = cl)set.seed(2) G <- 50; ng <- 5; n <- G * ng cl <- rep(seq_len(G), each = ng) z <- matrix(rnorm(n * 3), n, 3) u <- rnorm(G)[cl] x <- z %*% c(1, -1, 0.5) + u + rnorm(n) y <- 2 * x + u + rnorm(n) iv_compare(y, x, z, cluster = cl)