Repository navigation
Conversation
A missing value of a categorical or string variable was encoded as a row of zeros in the dummy columns, which kept the observation in the base category without a warning. It is now missing, so the observation is dropped with a MissingValueWarning, as with arrays. Closes bashtage#891
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #893 +/- ##
==========================================
- Coverage 99.69% 99.66% -0.03%
==========================================
Files 206 206
Lines 39413 39487 +74
Branches 2537 2549 +12
==========================================
+ Hits 39291 39355 +64
- Misses 52 58 +6
- Partials 70 74 +4
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:
|
This branch has not been deployed
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.
What
Formulas now treat a missing value of a categorical or string variable as missing, so the observation is dropped with a
MissingValueWarning, as it already is for array input. Applies to the formula parsers of the IV (includingAbsorbingLS), panel, system (SUR) and asset-pricing models.Why
formulaic encodes a missing categorical value as a row of zeros in the dummy columns, and linearmodels builds the matrices with
na_action="ignore". The observation was kept in the base category without a warning, soy ~ 1 + x + C(g)gave different estimates from the same data passed as arrays or afterdropna().How
model_matrix_from_formulainlinearmodels/shared/utility.pybuilds the matrix withna_action="ignore"and sets the dummy columns of a missing categorical value to NaN.model_matrix_from_specdoes the same, sopredict(data=...)gives NaN for such rows.IVFormulaParser,PanelFormulaParserand the asset-pricing parser use it. SUR usesIVFormulaParser.How to test
The new tests fail without the change. The IV, panel, system, asset-pricing and shared formula and utility tests pass.
Closes #891