Skip to content

BUG: Show the NewsResults details weights without rounding by the tolerance - #11131

Draft
bashtage wants to merge 2 commits into
statsmodels:mainfrom
bashtage:wip-news-weights-threshold
Draft

bashtage wants to merge 2 commits into
statsmodels:mainfrom
bashtage:wip-news-weights-threshold

Conversation

@bashtage

@bashtage bashtage commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

#11118, which this PR was stacked on, is merged. It changes the formatting of the weights in summary_details, whose row selection #11118 changed, and replaces #11078's test_summary_details_weights_below_tolerance, which required the old rounding. No conflict in news.py with #11081, #11082 or #11119; test_news.py conflicts with #11081, #11119 and the state_index revision impacts PR only where both append tests at the end of the file: keep both blocks.

BUG: Show the NewsResults details weights without rounding by the tolerance

The details tables of NewsResults.summary_details (and summary) showed a
weight as "1.0" when it was within NewsResults.tolerance of 1 and as "0"
when it was within the tolerance of 0. The tolerance is documented as the
threshold for which impacts are shown, so with tolerance=0.3 the weight
0.9 of the bivariate VAR(1) of the tests was shown as "1.0", and the
weights 0.1-0.28 of impacts above 0.3 as "0". With tolerance=0, the
weights that are 0 or 1 up to rounding errors were shown as "-0.0000" or
"1.0000" instead.

Changes

  • A weight is shown as "1.0" if it differs from one by less than 1e-10,
    and as "0" if it differs from zero by less than 1e-10 times the largest
    absolute weight of the same updated (revised) and impacted variables.
    The weights are in units of the impacted variable per unit of the
    updated variable, so the threshold for zero is relative to that pair:
    with one variable multiplied by 1e12, weights of about 1e-13 are shown
    with their values and the rounding errors of the weights 0 (about 1e-6)
    as "0". The tolerance only selects the rows.
  • The impacts are formatted as before (they were never shown as "0": only
    impacts larger than the tolerance in absolute value are in the table).
  • The weight column of the docstring says how the weights are shown, with
    a versionchanged note.

Not changed

  • The tables with the default tolerance (1e-10) for weights of the usual
    scale, the rows that are shown, and details_by_impact,
    details_by_update, revision_details_by_impact and the other properties.

Tests

  • test_summary_details_weights_not_rounded_by_tolerance (replaces
    test_summary_details_weights_below_tolerance, which required the old
    rounding): for the news (with and without revision details) and the
    revisions of the bivariate VAR(1), and the revisions of a variable
    without news, with tolerance 0, 1e-10 and 0.3, every weight of the
    table is "1.0" or "0" where the closed-form weight (I, 0 or a power of
    the transition matrix) is 1 or 0, and the closed-form value otherwise.
    The cases with tolerance 0 and 0.3 fail on the previous commit.

  • test_summary_details_weights_relative_to_scale: the same with one
    variable multiplied by 1e12 and a negative cross coefficient, with
    tolerance 0; the weights of about 1e-13 are shown with their values,
    the weights 0 of both pairs as "0" (fails on the previous commit).

  • test_summary_details_small_weights: in an AR(1) with phi = 0.001, the
    weights phi**k of the news and revisions are shown with their values
    down to 1e-9 and the weight 1 as "1.0", with tolerance 0 (fails on the
    previous commit, which shows the weight 1 as "1").

  • Two comments of existing tests that described the old rounding are
    updated.

  • 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.

  • No AI tools were used to develop this pull request.
  • AI tools were 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

…erance

The details tables of NewsResults.summary_details (and summary) showed a
weight as "1.0" when it was within NewsResults.tolerance of 1 and as "0"
when it was within the tolerance of 0. The tolerance is documented as the
threshold for which impacts are shown, so with tolerance=0.3 the weight
0.9 of the bivariate VAR(1) of the tests was shown as "1.0", and the
weights 0.1-0.28 of impacts above 0.3 as "0". With tolerance=0, the
weights that are 0 or 1 up to rounding errors were shown as "-0.0000" or
"1.0000" instead.

Changes
- A weight is shown as "1.0" if it differs from one by less than 1e-10,
  and as "0" if it differs from zero by less than 1e-10 times the largest
  absolute weight of the same updated (revised) and impacted variables.
  The weights are in units of the impacted variable per unit of the
  updated variable, so the threshold for zero is relative to that pair:
  with one variable multiplied by 1e12, weights of about 1e-13 are shown
  with their values and the rounding errors of the weights 0 (about 1e-6)
  as "0". The tolerance only selects the rows.
- The impacts are formatted as before (they were never shown as "0": only
  impacts larger than the tolerance in absolute value are in the table).
- The weight column of the docstring says how the weights are shown, with
  a versionchanged note.

Not changed
- The tables with the default tolerance (1e-10) for weights of the usual
  scale, the rows that are shown, and details_by_impact,
  details_by_update, revision_details_by_impact and the other properties.

Tests
- test_summary_details_weights_not_rounded_by_tolerance (replaces
  test_summary_details_weights_below_tolerance, which required the old
  rounding): for the news (with and without revision details) and the
  revisions of the bivariate VAR(1), and the revisions of a variable
  without news, with tolerance 0, 1e-10 and 0.3, every weight of the
  table is "1.0" or "0" where the closed-form weight (I, 0 or a power of
  the transition matrix) is 1 or 0, and the closed-form value otherwise.
  The cases with tolerance 0 and 0.3 fail on the previous commit.
- test_summary_details_weights_relative_to_scale: the same with one
  variable multiplied by 1e12 and a negative cross coefficient, with
  tolerance 0; the weights of about 1e-13 are shown with their values,
  the weights 0 of both pairs as "0" (fails on the previous commit).
- test_summary_details_small_weights: in an AR(1) with phi = 0.001, the
  weights phi**k of the news and revisions are shown with their values
  down to 1e-9 and the weight 1 as "1.0", with tolerance 0 (fails on the
  previous commit, which shows the weight 1 as "1").
- Two comments of existing tests that described the old rounding are
  updated.
@bashtage
bashtage force-pushed the wip-news-weights-threshold branch from a357393 to 60a2750 Compare November 28, 2026 21:36
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