Repository navigation
ENH: Add error_cov_start to choose the DynamicFactor error covariance start - #11133
Merged
bashtage merged 6 commits intoNov 25, 2026
Merged
Conversation
This was referenced Nov 24, 2026
4 of 5 tasks
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 24, 2026
With autoregressive errors (error_order > 0, error_var=False), DynamicFactor.start_params filled the error covariance parameters with the innovation variance of each series' autoregression whatever the error_cov_type, so with error_cov_type="scalar" (one parameter) or "unstructured" (k_endog (k_endog + 1) / 2 parameters) it raised "ValueError: could not broadcast input array from shape (3,) into shape (1,)" (or "(6,)"), and so did fit without start_params. Stacked on statsmodels#11133 (the start of an unstructured error covariance with VAR errors), which changes the neighbouring lines. Changes - As for white noise and VAR errors, the start is the mean of the innovation variances ("scalar") or the Cholesky factor of their diagonal matrix ("unstructured"); "diagonal" is unchanged. Not changed - error_cov_type="diagonal", and the other starting parameters. Tests (test_dynamic_factor.py) - Without factors and with an AR(1) error, and with a factor and AR(1) or AR(2) errors: the "scalar" and "unstructured" error covariance starts are the mean and the square roots (on the diagonal of the lower triangle) of the "diagonal" start, the other starting parameters equal those with "diagonal", and the "unstructured" start gives the log-likelihood of the "diagonal" start (the same covariance matrix). All six cases fail on statsmodels#11133.
bashtage
force-pushed
the
wip-dynamic-factor-unstructured-start
branch
from
November 24, 2026 16:18
05f4660 to
eccbbb6
Compare
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 24, 2026
With autoregressive errors (error_order > 0, error_var=False), DynamicFactor.start_params filled the error covariance parameters with the innovation variance of each series' autoregression whatever the error_cov_type, so with error_cov_type="scalar" (one parameter) or "unstructured" (k_endog (k_endog + 1) / 2 parameters) it raised "ValueError: could not broadcast input array from shape (3,) into shape (1,)" (or "(6,)"), and so did fit without start_params. Stacked on statsmodels#11133 (the start of an unstructured error covariance with VAR errors), which changes the neighbouring lines. Changes - As for white noise and VAR errors, the start is the mean of the innovation variances ("scalar") or the Cholesky factor of their diagonal matrix ("unstructured"); "diagonal" is unchanged. Not changed - error_cov_type="diagonal", and the other starting parameters. Tests (test_dynamic_factor.py) - Without factors and with an AR(1) error, and with a factor and AR(1) or AR(2) errors: the "scalar" and "unstructured" error covariance starts are the mean and the square roots (on the diagonal of the lower triangle) of the "diagonal" start, the other starting parameters equal those with "diagonal", and the "unstructured" start gives the log-likelihood of the "diagonal" start (the same covariance matrix). All six cases fail on statsmodels#11133.
…s models
Add tests of the paths of statespace/sarimax.py, varmax.py,
dynamic_factor.py, structural.py and exponential_smoothing.py that the TSA
test suite did not reach, each checked against an independent value:
- SARIMAX: the Hamilton representation with differencing raises; simple
differencing of a series with an int64 index 0, ..., n - 1 (replaced by
a RangeIndex starting at one) or a RangeIndex, with the forecast index
continuing at nobs and the forecasts phi**h times the last difference;
initialize_default with an approximate diffuse variance v (the first
observation of an ARIMA(0, 1, 0) has variance v + sigma2); explosive
seasonal AR and non-invertible seasonal MA starting parameters warn and
start at zero; the variances of time-varying coefficients are named
snr.x with a concentrated scale, whose likelihood equals the likelihood
at the scaled variances; trend_offset in extend_kwargs of forecast (a
drift-only model in closed form); arfreq and mafreq (the roots of
1 -/+ 0.5 L, None without roots); the summary model name with lag lists.
- VARMAX: explosive AR and MA starting parameters warn and start at zero;
the starting measurement variances are the residual variances of the
VAR(1) of the data or of its residuals (numpy least squares); fixing MA
parameters (individual ones raise, all of them give the likelihood at
the full parameter vector, marked in the summary); model.simulate with
exog of the wrong shape raises; extending results without smoother
output continues the filter of the full sample; a simulation without
shocks from an anchor (also negative) is the dynamic prediction with
exog after the sample, and an anchor after the sample raises; summary
with separate_params=False; a univariate VARMAX is the SARIMAX AR(1).
- DynamicFactor: explosive factor (AR and VAR) and error VAR starting
parameters raise, or are explosive without enforce_stationarity; with
VAR errors the scalar starting variance is the mean of the diagonal
ones; fixing error transition parameters (all or none for VAR(1) and
AR(2) errors, individually for AR(1) errors) against the likelihood at
the full parameters; factors with filter and smoother output and
without factors; coefficients_of_determination are squared
correlations, shown by the bars of plot_coefficients_of_determination
with and without labels; summary with separate_params=False.
- UnobservedComponents: invalid frequency domain seasonals raise; the
default cycle bounds of annual, quarterly, monthly and daily data and
the starting cycle frequency; transform_params and untransform_params of
an undamped cycle in closed form; a model with only an AR(1) (no trend
specification) is the SARIMAX AR(1), also cloned; initialize_default
with an approximate diffuse variance (local level in closed form);
starting parameters ignore missing observations; deterministic
seasonal, frequency domain seasonal and cycle components (parameters
and summary); the component properties against the state vector at the
documented offsets with filter and smoother output, and the components
that are not in the model; plot_components without the observed panel
and without dates.
- ExponentialSmoothing: the known initial state of pandas data without
dates, and of numpy data in the summary.
Bugs found, not fixed here, which the tests avoid: the summary of a VARMAX
with measurement error shows the measurement variance of the last series
in the table of the first one (and so on); a bool level + trend
UnobservedComponents without stochastic level or trend has no trend
specification ("Model: None" in the summary; _mask_map has the key 8 for
"fixed slope" instead of 10); the starting parameters of an
UnobservedComponents without level are NaN with missing data; the cycle
frequency of annual data does not start at a three-year cycle on
pandas >= 2.2 (which is why the annual start is not checked);
time_varying_regression=True without exog removes the state error of a
SARIMAX.
Coverage of the five files by the TSA tests (not slow) goes from 98.0% to
99.5% of the lines and from 94.7% to 97.9% of the branches for
sarimax.py, 95.4% to 98.5% and 87.0% to 92.2% for varmax.py, 97.2% to
99.2% and 87.2% to 95.3% for dynamic_factor.py, 95.4% to 98.8% and 84.1%
to 97.5% for structural.py, and from 98.7% to 100% of the branches for
exponential_smoothing.py (100% of the lines before and after). The lines
left are unreachable through the public API or have no effect, are
reachable only through one of the bugs above, or (the annual start of the
cycle frequency) only on pandas < 2.2.
Fix the docstrings of statespace/sarimax.py, varmax.py, dynamic_factor.py, structural.py and exponential_smoothing.py where they disagree with the code. No code changes. - UnobservedComponents: without annual, quarterly or monthly data the default cycle periods are at least 2 (the frequency is at most pi), not 0.5; **kwargs are documented. plot_components shows confidence intervals only for the one-step-ahead predictions of the observed series (not for the components), has one panel per selected component (one per frequency domain seasonal) and returns the figure. The component properties return None for components that are not in the model (an empty list for freq_seasonal), their smoothed estimates are None without smoother output, and regression_coefficients is None (with an OutputWarning) if the coefficients are estimated by maximum likelihood. clone, update, initialize_default, transform_params and untransform_params get docstrings or their missing sections. - DynamicFactor: the parameters are listed in the order of the signature; endog needs more than one series and k_factors must be less than their number. update returns nothing, and its Notes describe the whole parameter vector (regression coefficients, the three error covariance types, error transitions) and the order of the factor VAR coefficients (by equation, not one coefficient matrix after another); the docstring is raw, so its \times no longer renders as a tab. transform_params also constrains the error transition and only with enforce_stationarity. factors is None without factors; coefficients_of_determination are from regressions of the series on a factor (smoothed if available); plot_coefficients_of_determination returns the figure. - VARMAX: order is a sequence of int with default (1, 0) (a generator raises); the Attributes no longer repeat the defaults of the parameters; the Notes of transform_params describe the VARMAX constraints, not a factor transition. - SARIMAX: the seasonal autoregressive polynomial attribute is no longer described as moving average; concentrate_scale defaults to False and missing lists its values. initialize_default, clone and SARIMAXResults.extend (which continues the time trend and skips the constant exog check) get docstrings; arfreq and mafreq are None without roots; update returns the transformed parameters including the fixed ones. - ExponentialSmoothing: initialization_method lists its values and refers to initial_trend (not initial_slope); bounds is a sequence (it is indexed); clone gets a docstring; ExponentialSmoothingResults documents its parameters and initial_state (an array, or a one-row DataFrame for pandas data). - All five results classes document their constructor parameters, specification is a Bunch, and the coefficient matrices of VARMAX and DynamicFactor results are None without the corresponding lags; transform_params and untransform_params return ndarrays.
… start With VAR errors (error_order > 0, error_var=True) and error_cov_type="unstructured", DynamicFactor.start_params fits a VAR to the errors and computes the Cholesky factor of its residual covariance, with the identity matrix times the square root of the mean residual variance as the fallback when the factorization fails. A copy of the fallback after the try/except replaced the Cholesky factor in every case (both were added in 89500c5, 2015), so the error covariance always started at the scaled identity, and the correlations and different variances of the errors were ignored: for the Lutkepohl data of TestDFM_Gen (one factor, VAR(1) errors), cov.chol starts at [0.0629, 0, 0.0629, 0, 0, 0.0629] rather than the Cholesky factor [0.0501, 0.0336, 0.0549, 0.0387, 0.0597, 0.0123]. VARMAX starts its unstructured covariance at the Cholesky factor of the VAR residual covariance. The Cholesky start has a higher loglikelihood, but the fits from it are not always better: for these data, the starting loglikelihood is 404.27 instead of 300.84, but here the default fit (lbfgs, maxiter=50) reaches 418.93 instead of 460.31, and the lbfgs, nm, lbfgs chain of the skipped test_mle (maxiter=10000) 460.27 instead of 469.11. So both starts are available, and the default is unchanged. Changes - New keyword-only argument error_cov_start of DynamicFactor: "scaled_identity" (default) keeps the start of the scaled identity, "cholesky" starts at the Cholesky factor of the VAR residual covariance, with the scaled identity if the factorization fails. It has no effect without VAR errors or with a diagonal or scalar covariance. The names follow error_cov_type and the cov.chol parameters (the Cholesky factor of the error covariance). It is validated with string_like and case-sensitive, as error_cov_type is, and it is in the model's init keywords, so clone and pickling keep it. - Docstrings: the parameter and attribute (versionadded), and a short start_params docstring. Not changed - The default start values and fits of every model. Tests - test_start_params_error_var_unstructured: without factors (VAR(1) and VAR(2) errors) and with one factor (VAR(1) errors, on the residuals of the principal components), the start of cov.chol is the scaled identity by default and with "scaled_identity", and the lower triangle of the Cholesky factor with "cholesky", computed from a VAR without trend fitted with numpy least squares (nobs - lags - k_endog * lags degrees of freedom); the other starting parameters do not depend on the option. All cases fail on the previous commit, where the keyword does not exist (the default start matches the scaled identity there). - test_start_params_error_cov_start_no_effect: with white noise errors and an unstructured covariance, and with VAR errors and a diagonal or scalar covariance, both values give the same start. - test_error_cov_start_clone_pickle: clone and pickling keep the option, and clone can change it. - test_error_cov_start_invalid: "Cholesky" and "identity" raise a ValueError, and a positional value raises a TypeError.
The CodeQL check failed with "Call to DynamicFactor.__init__ with too many arguments" at the deliberate call with nine positional arguments in test_error_cov_start_invalid, which checks that error_cov_start is keyword only. Unpack the arguments from a list, which the analysis does not count, and match the message of the TypeError so that only the positional-argument error passes.
bashtage
force-pushed
the
wip-dynamic-factor-unstructured-start
branch
from
November 25, 2026 12:14
eccbbb6 to
d3a65ef
Compare
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 25, 2026
With autoregressive errors (error_order > 0, error_var=False), DynamicFactor.start_params filled the error covariance parameters with the innovation variance of each series' autoregression whatever the error_cov_type, so with error_cov_type="scalar" (one parameter) or "unstructured" (k_endog (k_endog + 1) / 2 parameters) it raised "ValueError: could not broadcast input array from shape (3,) into shape (1,)" (or "(6,)"), and so did fit without start_params. Stacked on statsmodels#11133 (the start of an unstructured error covariance with VAR errors), which changes the neighbouring lines. Changes - As for white noise and VAR errors, the start is the mean of the innovation variances ("scalar") or the Cholesky factor of their diagonal matrix ("unstructured"); "diagonal" is unchanged. Not changed - error_cov_type="diagonal", and the other starting parameters. Tests (test_dynamic_factor.py) - Without factors and with an AR(1) error, and with a factor and AR(1) or AR(2) errors: the "scalar" and "unstructured" error covariance starts are the mean and the square roots (on the diagonal of the lower triangle) of the "diagonal" start, the other starting parameters equal those with "diagonal", and the "unstructured" start gives the log-likelihood of the "diagonal" start (the same covariance matrix). All six cases fail on statsmodels#11133.
bashtage
marked this pull request as ready for review
November 25, 2026 16:10
bashtage
added a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 28, 2026
With autoregressive errors (error_order > 0, error_var=False), DynamicFactor.start_params filled the error covariance parameters with the innovation variance of each series' autoregression whatever the error_cov_type, so with error_cov_type="scalar" (one parameter) or "unstructured" (k_endog (k_endog + 1) / 2 parameters) it raised "ValueError: could not broadcast input array from shape (3,) into shape (1,)" (or "(6,)"), and so did fit without start_params. Stacked on statsmodels#11133 (the start of an unstructured error covariance with VAR errors), which changes the neighbouring lines. Changes - As for white noise and VAR errors, the start is the mean of the innovation variances ("scalar") or the Cholesky factor of their diagonal matrix ("unstructured"); "diagonal" is unchanged. Not changed - error_cov_type="diagonal", and the other starting parameters. Tests (test_dynamic_factor.py) - Without factors and with an AR(1) error, and with a factor and AR(1) or AR(2) errors: the "scalar" and "unstructured" error covariance starts are the mean and the square roots (on the diagonal of the lower triangle) of the "diagonal" start, the other starting parameters equal those with "diagonal", and the "unstructured" start gives the log-likelihood of the "diagonal" start (the same covariance matrix). All six cases fail on statsmodels#11133.
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.
Stacked on #11083, merge that first (its commits are the first ones here; this PR adds one commit). Merges cleanly with #11085-#11089 and #11121.
TST: Cover the SARIMAX, VARMAX, DynamicFactor and UnobservedComponents models
Add tests of the paths of statespace/sarimax.py, varmax.py,
dynamic_factor.py, structural.py and exponential_smoothing.py that the TSA
test suite did not reach, each checked against an independent value:
differencing of a series with an int64 index 0, ..., n - 1 (replaced by
a RangeIndex starting at one) or a RangeIndex, with the forecast index
continuing at nobs and the forecasts phi**h times the last difference;
initialize_default with an approximate diffuse variance v (the first
observation of an ARIMA(0, 1, 0) has variance v + sigma2); explosive
seasonal AR and non-invertible seasonal MA starting parameters warn and
start at zero; the variances of time-varying coefficients are named
snr.x with a concentrated scale, whose likelihood equals the likelihood
at the scaled variances; trend_offset in extend_kwargs of forecast (a
drift-only model in closed form); arfreq and mafreq (the roots of
1 -/+ 0.5 L, None without roots); the summary model name with lag lists.
the starting measurement variances are the residual variances of the
VAR(1) of the data or of its residuals (numpy least squares); fixing MA
parameters (individual ones raise, all of them give the likelihood at
the full parameter vector, marked in the summary); model.simulate with
exog of the wrong shape raises; extending results without smoother
output continues the filter of the full sample; a simulation without
shocks from an anchor (also negative) is the dynamic prediction with
exog after the sample, and an anchor after the sample raises; summary
with separate_params=False; a univariate VARMAX is the SARIMAX AR(1).
parameters raise, or are explosive without enforce_stationarity; with
VAR errors the scalar starting variance is the mean of the diagonal
ones; fixing error transition parameters (all or none for VAR(1) and
AR(2) errors, individually for AR(1) errors) against the likelihood at
the full parameters; factors with filter and smoother output and
without factors; coefficients_of_determination are squared
correlations, shown by the bars of plot_coefficients_of_determination
with and without labels; summary with separate_params=False.
default cycle bounds of annual, quarterly, monthly and daily data and
the starting cycle frequency; transform_params and untransform_params of
an undamped cycle in closed form; a model with only an AR(1) (no trend
specification) is the SARIMAX AR(1), also cloned; initialize_default
with an approximate diffuse variance (local level in closed form);
starting parameters ignore missing observations; deterministic
seasonal, frequency domain seasonal and cycle components (parameters
and summary); the component properties against the state vector at the
documented offsets with filter and smoother output, and the components
that are not in the model; plot_components without the observed panel
and without dates.
dates, and of numpy data in the summary.
Bugs found, not fixed here, which the tests avoid: the summary of a VARMAX
with measurement error shows the measurement variance of the last series
in the table of the first one (and so on); a bool level + trend
UnobservedComponents without stochastic level or trend has no trend
specification ("Model: None" in the summary; _mask_map has the key 8 for
"fixed slope" instead of 10); the starting parameters of an
UnobservedComponents without level are NaN with missing data; the cycle
frequency of annual data does not start at a three-year cycle on
pandas >= 2.2 (which is why the annual start is not checked);
time_varying_regression=True without exog removes the state error of a
SARIMAX.
Coverage of the five files by the TSA tests (not slow) goes from 98.0% to
99.5% of the lines and from 94.7% to 97.9% of the branches for
sarimax.py, 95.4% to 98.5% and 87.0% to 92.2% for varmax.py, 97.2% to
99.2% and 87.2% to 95.3% for dynamic_factor.py, 95.4% to 98.8% and 84.1%
to 97.5% for structural.py, and from 98.7% to 100% of the branches for
exponential_smoothing.py (100% of the lines before and after). The lines
left are unreachable through the public API or have no effect, are
reachable only through one of the bugs above, or (the annual start of the
cycle frequency) only on pandas < 2.2.
DOC: Correct the docstrings of the statespace models
Fix the docstrings of statespace/sarimax.py, varmax.py, dynamic_factor.py,
structural.py and exponential_smoothing.py where they disagree with the
code. No code changes.
default cycle periods are at least 2 (the frequency is at most pi), not
0.5; **kwargs are documented. plot_components shows confidence
intervals only for the one-step-ahead predictions of the observed series
(not for the components), has one panel per selected component (one per
frequency domain seasonal) and returns the figure. The component
properties return None for components that are not in the model (an
empty list for freq_seasonal), their smoothed estimates are None without
smoother output, and regression_coefficients is None (with an
OutputWarning) if the coefficients are estimated by maximum likelihood.
clone, update, initialize_default, transform_params and
untransform_params get docstrings or their missing sections.
endog needs more than one series and k_factors must be less than their
number. update returns nothing, and its Notes describe the whole
parameter vector (regression coefficients, the three error covariance
types, error transitions) and the order of the factor VAR coefficients
(by equation, not one coefficient matrix after another); the docstring
is raw, so its \times no longer renders as a tab. transform_params also
constrains the error transition and only with enforce_stationarity.
factors is None without factors; coefficients_of_determination are from
regressions of the series on a factor (smoothed if available);
plot_coefficients_of_determination returns the figure.
raises); the Attributes no longer repeat the defaults of the
parameters; the Notes of transform_params describe the VARMAX
constraints, not a factor transition.
described as moving average; concentrate_scale defaults to False and
missing lists its values. initialize_default, clone and
SARIMAXResults.extend (which continues the time trend and skips the
constant exog check) get docstrings; arfreq and mafreq are None without
roots; update returns the transformed parameters including the fixed
ones.
to initial_trend (not initial_slope); bounds is a sequence (it is
indexed); clone gets a docstring; ExponentialSmoothingResults documents
its parameters and initial_state (an array, or a one-row DataFrame for
pandas data).
specification is a Bunch, and the coefficient matrices of VARMAX and
DynamicFactor results are None without the corresponding lags;
transform_params and untransform_params return ndarrays.
ENH: Add error_cov_start to choose the DynamicFactor error covariance start
With VAR errors (error_order > 0, error_var=True) and
error_cov_type="unstructured", DynamicFactor.start_params fits a VAR to
the errors and computes the Cholesky factor of its residual covariance,
with the identity matrix times the square root of the mean residual
variance as the fallback when the factorization fails. A copy of the
fallback after the try/except replaced the Cholesky factor in every case
(both were added in 89500c5, 2015), so the error covariance always
started at the scaled identity, and the correlations and different
variances of the errors were ignored: for the Lutkepohl data of
TestDFM_Gen (one factor, VAR(1) errors), cov.chol starts at [0.0629, 0,
0.0629, 0, 0, 0.0629] rather than the Cholesky factor [0.0501, 0.0336,
0.0549, 0.0387, 0.0597, 0.0123]. VARMAX starts its unstructured
covariance at the Cholesky factor of the VAR residual covariance.
The Cholesky start has a higher loglikelihood, but the fits from it are
not always better: for these data, the starting loglikelihood is 404.27
instead of 300.84, but here the default fit (lbfgs, maxiter=50) reaches
418.93 instead of 460.31, and the lbfgs, nm, lbfgs chain of the skipped test_mle
(maxiter=10000) 460.27 instead of 469.11. So both starts are available,
and the default is unchanged.
Changes
"scaled_identity" (default) keeps the start of the scaled identity,
"cholesky" starts at the Cholesky factor of the VAR residual
covariance, with the scaled identity if the factorization fails. It has
no effect without VAR errors or with a diagonal or scalar covariance.
The names follow error_cov_type and the cov.chol parameters (the
Cholesky factor of the error covariance). It is validated with
string_like and case-sensitive, as error_cov_type is, and it is in the
model's init keywords, so clone and pickling keep it.
start_params docstring.
Not changed
Tests
test_start_params_error_var_unstructured: without factors (VAR(1) and
VAR(2) errors) and with one factor (VAR(1) errors, on the residuals of
the principal components), the start of cov.chol is the scaled identity
by default and with "scaled_identity", and the lower triangle of the
Cholesky factor with "cholesky", computed from a VAR without trend
fitted with numpy least squares (nobs - lags - k_endog * lags degrees of
freedom); the other starting parameters do not depend on the option.
All cases fail on the previous commit, where the keyword does not exist
(the default start matches the scaled identity there).
test_start_params_error_cov_start_no_effect: with white noise errors
and an unstructured covariance, and with VAR errors and a diagonal or
scalar covariance, both values give the same start.
test_error_cov_start_clone_pickle: clone and pickling keep the option,
and clone can change it.
test_error_cov_start_invalid: "Cholesky" and "identity" raise a
ValueError, and a positional value raises a TypeError.
tests added / passed.
code/documentation is well formatted.
properly formatted commit message. See
NumPy's guide.
AI Disclosure
Contributions must comply with the statsmodels AI Policy.
Tick exactly one of the following. If AI tools were used, replace the
<...>placeholders in the second option with the tool name(s) and how the tool's output was
used.
Tool(s): Claude Code (Claude Opus 5.5).
Used for: implementing the maintainer's decision, writing the tests against independent values, and checking them (tests failing on the base, mutation check).
I have personally read, understood, and can explain every line of this diff, and
have verified the statistical/numerical correctness of the change.
🤖 Generated with Claude Code