Commit f76cc42
committed
feat(engine): default fitting backend = mgcv::bam + gam escape (v0.1.1 Feature 4)
Implements Feature 4 of the locked v0.1.1 plan
(PLAN_v011_features.md §2.4) — the one non-byte-identical change
in the release. Documented loudly in NEWS.md and @details.
Engine dispatch
* New `engine = c("bam", "gam")` argument, default "bam" on both
janusplot() and janusplot_data(). bam is mgcv's "big additive
model" backend — block-Lanczos / fREML / lower memory.
~3-10x wall-time speedup at janusplot's scale (k = 15-25 vars,
600+ pairwise fits per call). No new dependency.
* `.fit_one_gam()` dispatch helper used at every fitting site
(initial fit + refit-on-flagged-cells under auto_refit_k =
TRUE) so the engine choice is consistent within a single call.
* `bam` objects inherit from `gam` (class is c("bam","gam","glm",
"lm")), so downstream code paths (k.check, predict, derivative
LP-matrix arithmetic, shape-metric extractors) are unaffected.
Method default
* `method` argument default is now NULL, resolved per-engine at
fit time: "fREML" for bam (mgcv's recommended at scale), "REML"
for gam (v0.1.0 behaviour). Users who passed method explicitly
in v0.1.0 see no behaviour change.
* User-supplied method (e.g. "GCV.Cp") overrides the per-engine
default — tested in test-engine.R.
bam-only knobs
* `discrete = FALSE` default. Opt-in to mgcv's covariate-
discretisation. Further ~2-5x speedup at sub-pixel prediction
shift cost.
* `nthreads = 1L` default. Intra-fit threading. Default 1 to
avoid CPU oversubscription when combined with parallel = TRUE
(which fans out across pair-fits via future.apply).
* Both ignored silently on engine = "gam".
Provenance
* `engine` + `method` columns appear in
janusplot(..., with_data = TRUE)$data and on every
janusplot_data()$pairs[[i]] entry. Paper figures can document
exactly which backend produced their EDFs.
Numerical-shift documentation
* NEWS.md leads with a NUMERICAL-SHIFT NOTICE block ABOVE the
per-feature entries — explicit callout of the ~1-3% EDF /
asymmetry index shift between v0.1.0 (REML) and v0.1.1
(fREML). Recovery via engine = "gam" stated prominently.
* @details on engine arg repeats the same.
* @PARAM method documents the new NULL default + per-engine
resolution.
Backward-compat escape
* Every v0.1.0 user can call janusplot(..., engine = "gam") and
get byte-identical fit results vs v0.1.0.
* The vdiffr visual-regression suite is now PINNED to
engine = "gam" precisely so the snapshots track the v0.1.0
visual contract; suite acts as a regression gate on the
backward-compat escape itself. Same pinning applied in
test-derivatives.R for the d1 derivative snapshots.
Tests: new tests/testthat/test-engine.R (10 expectations):
- default engine surfaces "bam" + "fREML" in with_data
- engine = "gam" surfaces "gam" + "REML"
- both engines agree to <10% relative shift on linear DGP
- both detect non-linearity on quadratic DGP (forward dir)
- discrete = TRUE on bam renders, silently ignored on gam
- explicit method overrides per-engine default
- invalid engine errors via arg_match
- janusplot_data carries engine + method per pair
devtools::test(): 473 expectations pass (was 449 after Feature 3).
R CMD check --no-manual: 0 errors / 0 warnings / 2 environmental
NOTEs (HTML Tidy + 4-component dev version). lintr 0 lints.
This completes the four-feature v0.1.1 plan. Next: vignette
expansion + CRAN-comments draft + version bump to 0.1.1.1 parent 151f261 commit f76cc42
8 files changed
Lines changed: 452 additions & 22 deletions
File tree
- R
- man
- tests/testthat
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
3 | 55 | | |
4 | 56 | | |
5 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
415 | 455 | | |
416 | 456 | | |
417 | 457 | | |
418 | 458 | | |
419 | 459 | | |
420 | 460 | | |
421 | 461 | | |
422 | | - | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
423 | 466 | | |
424 | 467 | | |
425 | 468 | | |
| |||
434 | 477 | | |
435 | 478 | | |
436 | 479 | | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
437 | 486 | | |
438 | | - | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
439 | 490 | | |
440 | 491 | | |
441 | 492 | | |
| |||
471 | 522 | | |
472 | 523 | | |
473 | 524 | | |
474 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
475 | 528 | | |
476 | 529 | | |
477 | 530 | | |
| |||
563 | 616 | | |
564 | 617 | | |
565 | 618 | | |
| 619 | + | |
| 620 | + | |
566 | 621 | | |
567 | 622 | | |
568 | 623 | | |
| |||
589 | 644 | | |
590 | 645 | | |
591 | 646 | | |
| 647 | + | |
592 | 648 | | |
593 | 649 | | |
594 | 650 | | |
| |||
618 | 674 | | |
619 | 675 | | |
620 | 676 | | |
621 | | - | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
622 | 681 | | |
623 | 682 | | |
624 | 683 | | |
| |||
640 | 699 | | |
641 | 700 | | |
642 | 701 | | |
643 | | - | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
644 | 705 | | |
645 | 706 | | |
646 | 707 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
29 | 59 | | |
30 | 60 | | |
31 | 61 | | |
| |||
354 | 384 | | |
355 | 385 | | |
356 | 386 | | |
357 | | - | |
| 387 | + | |
358 | 388 | | |
359 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
360 | 393 | | |
361 | 394 | | |
362 | 395 | | |
| |||
404 | 437 | | |
405 | 438 | | |
406 | 439 | | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
407 | 449 | | |
408 | 450 | | |
409 | 451 | | |
| |||
607 | 649 | | |
608 | 650 | | |
609 | 651 | | |
610 | | - | |
| 652 | + | |
| 653 | + | |
611 | 654 | | |
612 | 655 | | |
613 | 656 | | |
| |||
826 | 869 | | |
827 | 870 | | |
828 | 871 | | |
| 872 | + | |
| 873 | + | |
829 | 874 | | |
830 | 875 | | |
831 | 876 | | |
| |||
1020 | 1065 | | |
1021 | 1066 | | |
1022 | 1067 | | |
1023 | | - | |
| 1068 | + | |
1024 | 1069 | | |
1025 | 1070 | | |
1026 | 1071 | | |
| |||
1034 | 1079 | | |
1035 | 1080 | | |
1036 | 1081 | | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
1037 | 1085 | | |
1038 | 1086 | | |
1039 | 1087 | | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
1040 | 1097 | | |
1041 | 1098 | | |
1042 | 1099 | | |
| |||
1099 | 1156 | | |
1100 | 1157 | | |
1101 | 1158 | | |
1102 | | - | |
| 1159 | + | |
| 1160 | + | |
1103 | 1161 | | |
1104 | 1162 | | |
1105 | 1163 | | |
| |||
1163 | 1221 | | |
1164 | 1222 | | |
1165 | 1223 | | |
1166 | | - | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
1167 | 1227 | | |
1168 | 1228 | | |
1169 | 1229 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments