Repository navigation
BUG: Reject negative bandwidths in panel and IV kernel estimators - #887
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #887 +/- ##
=======================================
Coverage 99.69% 99.69%
=======================================
Files 202 203 +1
Lines 38871 38941 +70
Branches 2501 2503 +2
=======================================
+ Hits 38752 38822 +70
Misses 51 51
Partials 68 68
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Owner
|
Thanks. Makes sense to check. |
Contributor
Author
Thank you @bashtage |
This was referenced Dec 2, 2026
bashtage
added a commit
to echuq/linearmodels
that referenced
this pull request
Dec 3, 2026
…ir contributors bashtage#864 fixed the two-way clustered covariance of the IV models for float and string cluster labels, which 7.1 got wrong or rejected, and bashtage#878 made the clustered covariances faster, but neither had a 7.2 note. The note of the negative bandwidth fix cites bashtage#887 as well as bashtage#886, and the contributors of the pull requests merged since the list was started are thanked: echuq, AryanRG, soodoku, WeiLiuu and leninworld.
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.
This PR fixes issue #886.
Fixes #886
The panel and IV kernel estimators document
bandwidthas non-negative but accepted a negative value. With the Bartlett and Parzen kernels the result was that ofbandwidth=0; with the quadratic spectral kernel the standard errors could be very different (in the issue's example,-3shrinks them by roughly 30-40%).They now raise
ValueError: bandwidth must be non-negative., the message the system and asset-pricing estimators already use:DriscollKraay,ACCovarianceandFamaMacBethCovarianceKernelCovarianceKernelWeightMatrix(at construction) andIVGMMCovariancewithcov_type="kernel"bandwidth=None,0and positive values behave as before. ANaNbandwidth is not covered by this change.Verification:
linearmodels/tests/test_negative_bandwidth.py: the 12 negative-bandwidth cases fail onmainand pass here; the 12bandwidth=0cases pass on bothpytest linearmodels/tests: 23724 passed, 2473 skipped, 47 xfailed (macOS, Python 3.12)flake8,black --check,isort --check,ruff checkon the changed files pass;mypyreports the same errors asmain