R/inference.R
GetL3OCIcoef_fast.RdCalculates the coefficients \((a, b, c)\) for the confidence interval quadratic inequality
in a general design that includes both grouping (stratification) and covariates.
This function is optimized for designs where projection matrices are block-diagonal
with respect to groupW but potentially asymmetric within blocks due to covariate adjustments.
GetL3OCIcoef_fast(
df,
groupW,
groupQ,
X,
Y,
MX,
MY,
q = qnorm(0.975)^2,
noisy = FALSE
)Data frame. Contains the observable variables and grouping indicators.
Column name (unquoted). The covariate stratification variable.
Column name (unquoted). The instrument grouping variable.
Column name (unquoted). The endogenous regressor.
Column name (unquoted). The outcome variable.
Column name (unquoted). Leverage-adjusted regressor (\(M X\)).
Column name (unquoted). Leverage-adjusted outcome (\(M Y\)).
Numeric scalar. The critical value for test inversion (typically \(1.96^2\)).
Defaults to qnorm(.975)^2.
Logical. If TRUE, prints progress.
Defaults to FALSE.
Numeric vector of length 3 containing c(a, b, c).
This function performs a loop:
Splits data by groupW. Computes local projection matrices
\(P_Q\) and \(P_W\) for each stratum.
Calculates the full UJIVE weighting matrix \(G = U(P_Q) - U(P_W)\) locally. Since \(G\) is asymmetric, it computes all 5 variance components.
Accumulates all polynomial coefficients for \(\hat{V}(\beta)\) simultaneously using extensive pre-calculation of vector products.
Yap, L. (2025). "Inference with Many Weak Instruments and Heterogeneity". Working Paper.