R/inference.R
GetCIcoef_iloop_nocov.RdCalculates the coefficients \((a, b, c)\) for the confidence interval quadratic inequality in the "No Covariates" setting (\(G = P\)), but for general symmetric projection matrices. This function performs a highly optimized single-pass loop to compute all polynomial coefficients of the variance estimator \(\hat{V}(\beta)\) simultaneously.
GetCIcoef_iloop_nocov(X, Y, P, q = qnorm(0.975)^2, noisy = FALSE)Numeric vector of length n. The endogenous regressor.
Numeric vector of length n. The outcome variable.
Matrix of dimension n x n. The symmetric projection matrix.
Numeric scalar. The critical value for the test inversion (typically \(1.96^2\)).
Defaults to qnorm(0.975)^2.
Logical. If TRUE, prints progress through the N loops.
Defaults to FALSE.
Numeric vector of length 3 containing c(a, b, c).
This function is the solver for generic symmetric designs. It inverts the test statistic: $$\frac{(P_{XY} - \beta P_{XX})^2}{C_2 \beta^2 + C_1 \beta + C_0} \leq q$$
Optimization: Rather than calling variance estimators multiple times, it decomposes the variance formula into geometric components (depending only on \(P\)) and data components (\(X, Y\)). It iterates through observations \(i\) once, accumulating the weighted contributions for \(C_0\), \(C_1\), and \(C_2\) in parallel.
Yap, L. (2025). "Inference with Many Weak Instruments and Heterogeneity". Working Paper.