Skip to content

BUG: Fix the layout of the standard errors of LinearFactorModelGMM - #781

Merged
bashtage merged 1 commit into
mainfrom
lm71-fix-gmm-factor-std-errors
Oct 12, 2026
Merged

bashtage merged 1 commit into
mainfrom
lm71-fix-gmm-factor-std-errors

Conversation

@bashtage

Copy link
Copy Markdown
Owner

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.

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

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.59%. Comparing base (6cbd30b) to head (5a72869).
⚠️ Report is 34 commits behind head on main.

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     
Flag Coverage Δ
adder 99.57% <100.00%> (+0.01%) ⬆️
subtractor 99.57% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bashtage
bashtage merged commit bcfb9be into main Oct 12, 2026
24 checks passed
@bashtage
bashtage deleted the lm71-fix-gmm-factor-std-errors branch October 12, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant