Skip to content

BUG: Make nobs of the system results the number of observations of ea… - #803

Merged
bashtage merged 1 commit into
mainfrom
lm71-system-nobs-per-equation
Oct 13, 2026
Merged

bashtage merged 1 commit into
mainfrom
lm71-system-nobs-per-equation

Conversation

@bashtage

Copy link
Copy Markdown
Owner

…ch equation

SystemResults.nobs of SUR, IV3SLS and IVSystemGMM was the number of observations of all the equations, nobs * neq, the number of elements of the residuals. The summary of the same results reports the number of observations of each equation, as "No. Observations", the results of each equation have nobs equal to that number, and every other model has the number of observations of the sample. A system of 3 equations with 120 observations had nobs equal to 360.

nobs is now the number of observations of each equation: 120 in the example. All the equations of a system use the same observations. A missing value in a variable of any equation drops the row from all the equations, and the models raise an error if the equations are given with different numbers of observations ("All equations must have the same number of observations"), so that this number is the same for every equation and there is no other rule to choose.

The count of the observations of all the equations is still needed, by df_resid (nobs * neq less the number of parameters), and so by the p-values and the confidence intervals of a debiased covariance. SystemResults computes it from nobs and the number of equations, and nothing else changes: df_resid, the p-values and the confidence intervals are numerically the same. The summary prints nobs. The results of each equation already had nobs per equation, and their F-statistics do not change. There is no model comparison for the system models.

test_nobs.py checks nobs, the summary, the shapes of the residuals, df_resid and the degrees of freedom of the p-values and confidence intervals against an independent computation, the effect of missing values, and the error for equations with different numbers of observations, for SUR, IV3SLS and IVSystemGMM with GLS and OLS (10 of its 23 tests fail before the change, the others check what does not change). test_missing_values.py compared nobs with nobs * neq for the system model.

The docstring of SystemResults, nobs and df_resid describe the definitions and the change.

…ch equation

SystemResults.nobs of SUR, IV3SLS and IVSystemGMM was the number of observations
of all the equations, nobs * neq, the number of elements of the residuals. The
summary of the same results reports the number of observations of each equation,
as "No. Observations", the results of each equation have nobs equal to that
number, and every other model has the number of observations of the sample. A
system of 3 equations with 120 observations had nobs equal to 360.

nobs is now the number of observations of each equation: 120 in the example.
All the equations of a system use the same observations. A missing value in a
variable of any equation drops the row from all the equations, and the models
raise an error if the equations are given with different numbers of
observations ("All equations must have the same number of observations"), so
that this number is the same for every equation and there is no other rule to
choose.

The count of the observations of all the equations is still needed, by
df_resid (nobs * neq less the number of parameters), and so by the p-values and
the confidence intervals of a debiased covariance. SystemResults computes it
from nobs and the number of equations, and nothing else changes: df_resid, the
p-values and the confidence intervals are numerically the same. The summary
prints nobs. The results of each equation already had nobs per equation, and
their F-statistics do not change. There is no model comparison for the system
models.

test_nobs.py checks nobs, the summary, the shapes of the residuals, df_resid and
the degrees of freedom of the p-values and confidence intervals against an
independent computation, the effect of missing values, and the error for
equations with different numbers of observations, for SUR, IV3SLS and
IVSystemGMM with GLS and OLS (10 of its 23 tests fail before the change, the
others check what does not change). test_missing_values.py compared nobs with
nobs * neq for the system model.

The docstring of SystemResults, nobs and df_resid describe the definitions and
the change.
for key in results.individual:
self._individual[key] = SystemEquationResult(results.individual[key])
# The residual degrees of freedom count the observations of all equations
self._df_resid = len(self._individual) * self._nobs - self._df_model
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.61%. Comparing base (9fa3a90) to head (1324114).
⚠️ Report is 53 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #803      +/-   ##
==========================================
+ Coverage   99.60%   99.61%   +0.01%     
==========================================
  Files         136      140       +4     
  Lines       26057    28098    +2041     
  Branches     1873     1976     +103     
==========================================
+ Hits        25954    27991    +2037     
- Misses         38       41       +3     
- Partials       65       66       +1     
Flag Coverage Δ
adder 99.60% <100.00%> (+0.01%) ⬆️
subtractor 99.60% <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 f560d52 into main Oct 13, 2026
24 checks passed
@bashtage
bashtage deleted the lm71-system-nobs-per-equation branch October 13, 2026 10:33
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.

2 participants