Skip to content

BUG: Use the Powell kernel sandwich for QuantReg robust covariance - #11281

Open
bhaskargurram-ai wants to merge 4 commits into
statsmodels:mainfrom
bhaskargurram-ai:fix/quantreg-robust-cov
Open

bhaskargurram-ai wants to merge 4 commits into
statsmodels:mainfrom
bhaskargurram-ai:fix/quantreg-robust-cov

Conversation

@bhaskargurram-ai

Copy link
Copy Markdown
Contributor

Closes #10782.

QuantReg.fit(vcov="robust"), the default, used one kernel estimate of the error density for all observations, so the covariance converged to the iid one and was identical to vcov="iid" at q=0.5. It now uses the Powell (1991) kernel sandwich, which estimates the density at each observation with the kernel and bandwidth the fit already uses:

fhat_i = K(e_i / h) / h
V = q (1 - q) (X' F X)^-1 X'X (X' F X)^-1,   F = diag(fhat)

On the Engel data the standard error of the income coefficient at the median goes from 0.0132 (the same as iid) to 0.0373 with kernel="gau", or 0.0314 with the default Epanechnikov kernel. R's quantreg gives 0.0373 for se="ker" and 0.0283 for se="nid". If the bandwidth is not defined (very small samples, q +- h outside (0, 1)), the covariance is nan, as before.

Tests:

  • test_robust_vcov_rquantreg compares the standard errors at q = 0.25, 0.5, 0.75 with R quantreg 6.1 summary(rq(foodexp ~ income, tau = q, data = engel), se = "ker") (rtol 1e-7).
  • test_robust_vcov_heteroskedastic checks that robust and iid differ at q = 0.5 with heteroskedastic errors.

Both fail on main and pass with the change. The regression values in test_zero_resid were updated to the new covariance; the Stata comparisons all use vcov="iid" and are unchanged. The docstrings describe the change of the default numbers; I'll add the release-note fragment once the PR has a number.

  • tests added / passed.
  • code/documentation is well formatted.
  • properly formatted commit message. See
    NumPy's guide.

AI Disclosure

Contributions must comply with the statsmodels AI Policy.

  • No AI tools were used to develop this pull request.
  • AI tools were used.
    Tool(s): Claude Code.
    Used for: drafting the tests and this PR description.
    I have personally read, understood, and can explain every line of this diff, and
    have verified the statistical/numerical correctness of the change.

vcov="robust" used one density estimate for all observations, so it was
not robust to heteroskedasticity and was identical to vcov="iid" at
q=0.5. Estimate the density at each observation, as in R quantreg
summary.rq(se="ker"), and test against R.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QuantReg default vcov="robust" is not heteroskedasticity robust (identical to "iid" at q=0.5)

1 participant