Skip to content

feat(gam): add mgcv Markov random field smooths - #32

Merged
Ananyapam7 merged 1 commit into
mainfrom
feature/mgcv-wave2-mrf
Aug 25, 2026
Merged

feat(gam): add mgcv Markov random field smooths#32
Ananyapam7 merged 1 commit into
mainfrom
feature/mgcv-wave2-mrf

Conversation

@Ananyapam7

Copy link
Copy Markdown
Collaborator

Summary

  • port mgcv 1.9-4 smooth.construct.mrf.smooth.spec, Predict.matrix.mrf.smooth, pol2nb, and nat.param(type=0) behavior
  • support graph, polygon, and supplied-penalty MRFs across full/reduced rank, ordinary/numeric/factor by, select, fx, linked same-feature id, te/ti, numeric-coded fs/sz, array construction, prediction, and persistence
  • add 21 static upstream fixtures, executed docs, taxonomy, and explicit malformed/safety boundaries

Upstream sources

  • nampy_notes/upstreams/mgcv/R/smooth.r:2668-2875
  • nampy_notes/upstreams/mgcv/R/smooth.r:15-129 (nat.param)
  • generic smoothCon constraints/selection and tensor/factor-smooth constructors in the same vendored file

Validation

  • 25 passed: MRF raw-constructor and integrated parity slice
  • 22 passed: te/ti stage and natural-parameter owner tests
  • 17 passed: structured categorical/tensor pipeline regressions
  • 2 passed: focused MRF fs/sz regression after metadata propagation
  • touched-file Ruff checks and git diff --check
  • executed and normalized docs/notebooks/01_gam.ipynb
  • taxonomy collection selects all 25 MRF cases

Expected warnings: the two numeric-coded factor-smooth cases preserve mgcv warning that an MRF argument should be a factor.

Explicit boundaries

  • reject malformed reduced-rank k<=2, MRF pc, mixed named/numeric neighbor lists, cross-feature MRF id, and reduced-rank MRF-inside-fs prediction
  • unknown prediction regions raise a clear error instead of mgcv s later subscript failure
  • direct penalties are normalized through NAMpy s symmetric penalty subsystem
  • t2 and polygon-specific plot.mrf.smooth rendering remain outside this bounded constructor subwave

@Ananyapam7
Ananyapam7 merged commit b165015 into main Aug 25, 2026
6 of 8 checks passed
@Ananyapam7
Ananyapam7 deleted the feature/mgcv-wave2-mrf branch August 25, 2026 00:03
Ananyapam7 added a commit that referenced this pull request Aug 25, 2026
Co-authored-by: Ananyapam De <ananyapam7@tu-clausthal.de>
Ananyapam7 added a commit that referenced this pull request Aug 25, 2026
Co-authored-by: Ananyapam De <ananyapam7@tu-clausthal.de>
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