Skip to content

[FEAT] Apply the degree-of-freedom adjustment in BootstrapODPSample when the hat matrix is not used #1618

Open

Description

@scks1

Description

Follow-up to #1603 and #1616. With hat_adj=False, and when the hat matrix can't be computed, BootstrapODPSample resamples the unscaled Pearson residuals with no adjustment (L244–L247). The degree-of-freedom factor in fit was never applied (see the blame in #1603) and is commented out (L225–L229).

Shapland and Leong ("Bootstrap Modeling: Beyond the Basics", CAS E-Forum, Fall 2010, pp. 13–14) give the factor as eq. (3.22), f = sqrt(N / (N − p)), with N residuals and p parameters. They note that England and Verrall (2002) multiply the Pearson residuals by it to correct for a bias, and that the hat matrix factor (3.24) replaces it, so the two are alternatives.

Is your feature request aligned with the scope of the package?

  • Yes, absolutely!
  • No, but it's still worth discussing.
  • N/A (this request is not a codebase enhancement).

Describe the solution you'd like, or your current workaround.

  • When hat_ is None, multiply the unscaled residuals by sqrt(N / (N − p)) before resampling, using the N and p that scale_ already uses (degree_freedom in _get_simulation). scale_ doesn't change; resampled_triangles_ changes for hat_adj=False and for the fallback, and the default path is untouched.
  • Update the hat_adj docstring, which since [FIX] Leave hat_adj unchanged when the hat matrix cannot be computed #1616 says those residuals are resampled without an adjustment, to say the degree-of-freedom factor is applied.

If you'd rather keep hat_adj=False unadjusted and add the factor as its own option, that works too.

Do you have any additional supporting notes?

Test: on genins (10 × 10), N = 55 and p = 19, so f = sqrt(55/36) = 1.2360. With the same random_state, each resampled incremental's distance from its fitted value is 1.2360 times what hat_adj=False gives today, because dropping zero residuals and centering them both commute with a constant factor.

Would you be willing to contribute this ticket?

  • Yes, absolutely!
  • Yes, but I would like some help.
  • No.

(This issue was written with Árbol, an AI assistant, under my direction.)

Activity

  1. updated Priority Low, Scope Codebase and Effort Medium on Nov 19, 2026
  2. removed
    Great First Contribution! 🌱Beginner friendly tickets with narrow scope and huge impact. Perfect to get your feet wet!
    on Nov 19, 2026
  3. added this to the v2.0.0 milestone on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    Low

    Scope

    Codebase

    Effort

    Medium

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions