Skip to content

Improve p-value computation using truncated eigendecomposition (Wood 2014)#550

Open
Kinara2020 wants to merge 7 commits intodswah:mainfrom
Kinara2020:wood2014_pvalue_fix
Open

Improve p-value computation using truncated eigendecomposition (Wood 2014)#550
Kinara2020 wants to merge 7 commits intodswah:mainfrom
Kinara2020:wood2014_pvalue_fix

Conversation

@Kinara2020
Copy link
Copy Markdown

@Kinara2020 Kinara2020 commented Mar 23, 2026

Summary
This PR updates the way p-values are computed for smooth terms in pyGAM.

The current implementation uses a pseudoinverse of the covariance matrix
following Wood (2006). However, this approach can lead to overly small
p-values when smoothing parameters are estimated, which is a limitation
already mentioned in the warning message in the library.

To address this, I replaced the pseudoinverse-based computation with a
rank-r truncated eigendecomposition approach based on Wood (2013).
By removing near-zero eigenvalues before computing the test statistic,
the method avoids unstable directions in the covariance matrix and
produces more reliable p-values.

Changes

  • Replaced the pseudoinverse-based covariance inversion with a truncated eigendecomposition
  • Filtered near-zero eigenvalues using a numerical stability threshold
  • Computed the Wald-type statistic using the truncated eigenbasis
  • Kept the existing chi-squared and F-statistic logic unchanged

Testing
All existing tests pass locally.

Note
While running the test suite locally, the only failing test encountered
was related to the known Tkinter plotting issue, which appears unrelated
to this change.

References
Wood, S.N. (2013)
"On p-values for smooth components of an extended generalized additive model"
Biometrika 100(1):221–228.

@Kinara2020 Kinara2020 changed the title Improve p-value computation using truncated eigendecomposition (Wood 2013) Improve p-value computation using truncated eigendecomposition (Wood 2014) Mar 23, 2026
@Kinara2020
Copy link
Copy Markdown
Author

Hi @dswah,

Thank you for maintaining this project!

While reviewing the p-value computation and its associated references in pyGAM, I worked on this change to improve clarity and ensure the messaging more accurately reflects the underlying statistical formulation described in the literature.

I’ve verified that all CI checks pass locally, and confirmed that the change does not introduce any functional differences beyond improving the warning/documentation.

If there are any suggestions regarding the wording, structure, or if additional validation/tests would be helpful, I’d be glad to refine this further.

Thanks again for your time and for your work on pyGAM!

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