Repository navigation
BUG: Use the Powell kernel sandwich for QuantReg robust covariance - #11281
Open
bhaskargurram-ai wants to merge 4 commits into
Open
bhaskargurram-ai wants to merge 4 commits into
bhaskargurram-ai wants to merge 4 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tovcov="iid"atq=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: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 forse="ker"and 0.0283 forse="nid". If the bandwidth is not defined (very small samples,q +- houtside (0, 1)), the covariance is nan, as before.Tests:
test_robust_vcov_rquantregcompares the standard errors at q = 0.25, 0.5, 0.75 with R quantreg 6.1summary(rq(foodexp ~ income, tau = q, data = engel), se = "ker")(rtol 1e-7).test_robust_vcov_heteroskedasticchecks 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_residwere updated to the new covariance; the Stata comparisons all usevcov="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.NumPy's guide.
AI Disclosure
Contributions must comply with the statsmodels AI Policy.
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.