Skip to main content

Module smooth_test

Module smooth_test 

Source
Expand description

Wood-style smooth-component Wald tests.

The test follows the rank-truncated covariance inverse used by Wood (2013): the penalized part of the coefficient block is tested with a pseudo-inverse of rank approximately equal to the term EDF, while unpenalized null-space coefficients are kept full-rank. The reference degrees of freedom use the coefficient-space influence block F_jj = (H⁻¹ X'WX)_jj.

Bartlett and Lawley mean corrections are likelihood-ratio corrections, so they are not applied here. In the ordinary unpenalized Gaussian model the Wald statistic satisfies T / q ~ F(q, ν) exactly, while under a ridge penalty even the one-parameter statistic becomes (n / (n + λ))χ²₁ rather than a central χ²/F reference target.

Structs§

SmoothTestInput
Inputs to wood_smooth_test. beta is the full coefficient vector; the term block being tested is beta[coeff_range]. covariance is the matching posterior covariance Σ̂ (full p×p; the diagonal block is sliced out). covariance must be the scale-included posterior covariance (mgcv Vb/Vp, i.e. H⁻¹ already multiplied by the dispersion φ̂), so the Wald statistic T = β̂'·Σ̂⁻·β̂ is dimensionless — the residual dispersion has already been divided out and the F-statistic is T/ref_df with no further φ̂ factor. influence_matrix is the optional coefficient-space influence F = H⁻¹ X'WX; when present tr(F_jj)² / tr(F_jj²) is used as the Wood-corrected reference d.f. edf is the smooth’s effective d.f. (rank truncation for the penalized subblock); nullspace_dim is the fixed-effect (unpenalized) leading dimension within the block. residual_df is the denominator d.f. for the Estimated-scale F branch.
SmoothTestResult
Output of wood_smooth_test: the Wald statistic T = β̂'·Σ̂⁻ᵣ·β̂ (rank-r pseudo-inverse on the penalized subblock, full-rank on the nullspace subblock), the reference d.f. used to compute the tail probability, and the resulting p_value (clamped to [0,1]).

Enums§

SmoothTestScale
Whether the residual dispersion φ is known or estimated from the fit. Selects the reference distribution for the Wald p-value: Knownχ²_{ref_df} (e.g. binomial/Poisson), EstimatedF_{ref_df, residual_df} (e.g. Gaussian where φ̂ carries its own sampling variability).

Functions§

wood_smooth_test
Wood (2013) rank-truncated Wald smooth-component test.