Repository navigation
BUG: Fix the layout of the standard errors of LinearFactorModelGMM - #781
Merged
Merged
Conversation
GMMFactorModelResults.std_errors stacked the standard errors of the alphas on top of the standard errors of the loadings, and reshaped the vector to one row for each portfolio. Row i of the table then held the alphas of portfolios i(k+1) to i(k+1)+k instead of the alpha and the loadings of portfolio i, where k is the number of factors. The cells of the table were wrong for every model with more than one portfolio, and so were tstats, pvalues and the loadings in full_summary, which are computed from std_errors. For a model with 6 portfolios and 2 factors, the loading of the first portfolio on the first factor, 0.7037, had a standard error of 0.00143, which is the standard error of the alpha of the second portfolio, where the standard error in cov is 0.0270. Its t-statistic was 491 instead of 26. The alphas and the standard errors of the risk premia were not affected, and neither were the other result classes. The standard errors of the alphas are now the first column and the standard errors of the loadings of each portfolio follow in the other columns, as they do for LinearFactorModel and TradedFactorModel. The test compares the table with the standard errors in cov, found from the names of the parameters, and with the standard errors of the alphas. It fails without the change for one and for three factors, with and without a risk-free rate.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #781 +/- ##
==========================================
+ Coverage 99.58% 99.59% +0.01%
==========================================
Files 128 128
Lines 24188 24452 +264
Branches 1809 1822 +13
==========================================
+ Hits 24087 24353 +266
+ 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.
GMMFactorModelResults.std_errors stacked the standard errors of the alphas on top of the standard errors of the loadings, and reshaped the vector to one row for each portfolio. Row i of the table then held the alphas of portfolios i(k+1) to i(k+1)+k instead of the alpha and the loadings of portfolio i, where k is the number of factors. The cells of the table were wrong for every model with more than one portfolio, and so were tstats, pvalues and the loadings in full_summary, which are computed from std_errors.
For a model with 6 portfolios and 2 factors, the loading of the first portfolio on the first factor, 0.7037, had a standard error of 0.00143, which is the standard error of the alpha of the second portfolio, where the standard error in cov is 0.0270. Its t-statistic was 491 instead of 26. The alphas and the standard errors of the risk premia were not affected, and neither were the other result classes.
The standard errors of the alphas are now the first column and the standard errors of the loadings of each portfolio follow in the other columns, as they do for LinearFactorModel and TradedFactorModel.
The test compares the table with the standard errors in cov, found from the names of the parameters, and with the standard errors of the alphas. It fails without the change for one and for three factors, with and without a risk-free rate.