Computes Conley (1999) spatial HAC variance-covariance matrices for models
estimated with lfe::felm() (OLS and IV/2SLS) or with
fixest's feols() (OLS and IV), feglm(), and
fepois(). For GLM fits the variance is the M-estimation sandwich
built from the stored score matrix and inverse Hessian. The spatial
meat uses a fast CSR/cumulative-score implementation in C++; see
vcovSpHAC.felm and vcovSpHAC.fixest for the
per-method argument lists.
Value
A numeric matrix (base "matrix") of dimension k x k,
where k is the number of estimated coefficients (absorbed fixed
effects excluded): the Conley spatial HAC estimate of the
variance-covariance matrix of the coefficient estimates, i.e. the
sandwich bread %*% meat %*% bread with the kernel-weighted
spatial (and, with lag_cutoff > 0, serial) cross products in
the meat. Row and column names are the coefficient names of the fit, so
the matrix can be passed wherever a vcov is expected, e.g.
lmtest::coeftest(reg, vcov = V) or
summary(reg, vcov = V) for fixest fits, and sqrt(diag(V))
gives the standard errors. The matrix is symmetric; with the default
ssc = TRUE it is scaled by n / (n - K), and with the
default psd_fix = TRUE it is positive semi-definite.