Repository navigation
BUG: Drop observations with missing values for asset pricing models f… - #777
Merged
Merged
Conversation
…rom formulas TradedFactorModel, LinearFactorModel and LinearFactorModelGMM drop the observations that have a missing value in the portfolios or in the factors, with a MissingValueWarning, when they are made from arrays or data frames. A model made with from_formula raised "ValueError: Error encountered while checking for nulls in `port_02`" for a missing value in a factor or in a portfolio that the formula names, because the formula parser asked for na_action="raise". A missing value in the data frame passed in portfolios was dropped, so the same data gave an error or an estimate according to where the formula took the variable from. The parser keeps the missing values now (na_action="ignore") and the model drops the observations with a missing value in any of the portfolios or the factors, in the same way as for arrays. This is the same change that the IV and system formula parsers got. The tests make the model from the formula, with the portfolios in the formula and in the portfolios argument, and compare the data of the model, and the parameters, with the model made from the data after the rows with a missing value were dropped. They fail without the change.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #777 +/- ##
==========================================
+ Coverage 99.58% 99.59% +0.01%
==========================================
Files 128 128
Lines 24188 24454 +266
Branches 1809 1822 +13
==========================================
+ Hits 24087 24355 +268
+ Misses 40 39 -1
+ Partials 61 60 -1
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 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.
…rom formulas
TradedFactorModel, LinearFactorModel and LinearFactorModelGMM drop the observations that have a missing value in the portfolios or in the factors, with a MissingValueWarning, when they are made from arrays or data frames. A model made with from_formula raised "ValueError: Error encountered while checking for nulls in
port_02" for a missing value in a factor or in a portfolio that the formula names, because the formula parser asked for na_action="raise". A missing value in the data frame passed in portfolios was dropped, so the same data gave an error or an estimate according to where the formula took the variable from.The parser keeps the missing values now (na_action="ignore") and the model drops the observations with a missing value in any of the portfolios or the factors, in the same way as for arrays. This is the same change that the IV and system formula parsers got.
The tests make the model from the formula, with the portfolios in the formula and in the portfolios argument, and compare the data of the model, and the parameters, with the model made from the data after the rows with a missing value were dropped. They fail without the change.