Which end of the ψ bound the shared aniso_bounds_from_data helper is
computing. The lower end uses -max_length_scale.ln() as the pure-Duchon
fallback and the .0 element of spatial_term_psi_bounds; the upper end
uses -min_length_scale.ln() and .1. Everything else is identical.
Hard positive cap on |κ| relative to the data’s inverse squared chart
radius. The κ-stereographic chart is valid for 1 + κ‖x‖² > 0; at
|κ| = 1/R² (R² = max squared chart radius) the gauge 1 + κ‖x‖² reaches
the chart edge for the farthest data point, so the optimizer is boxed to a
safe fraction of that scale on both sides. κ = 0 (flat) is the centre of
the window, an interior point of the S^d ← ℝ^d → H^d family — exactly the
reachability the raw-κ (not log-κ) coordinate exists to preserve.
Floor on the data’s squared chart radius used to scale the κ window, so a
degenerate (near-origin) point cloud still yields a finite, usable bracket
rather than an unbounded one.
Upper edge of the data-derived kernel-range window, as a multiple of the
minimum pairwise distance r_min: beyond 100/r_min the radial columns go
nearly collinear with the polynomial nullspace, so the kernel range is
capped here to keep the basis geometry well-conditioned.
Measure-jet ψ dial boxes. The dials are NOT log-kernel-scales, so the
κ-window machinery never applies: α spans density-weighted (0) through
past-Coifman–Lafon (>1) normalization, and lnτ covers the ridge from
numerically-exact-projection to heavy noise-floor damping. (The energy
order s is the pinned explicit value or absorbed by the REML-learned
per-scale amplitudes — see measure_jet_penalty_psi_dim — so it carries no
dial box.)
Log-ℓ box for the design-moving representer length-scale dial (#1116). An
ABSOLUTE window in the data coordinate scale (ln of ℓ ∈ [1e-3, 1e2]) used
only when the spec explicitly enrolls the learned representer range. Absolute
(not seed-relative) so the bound producer needs no data view, matching the
other dial boxes. ln(1e-3) = -6.9077…, ln(1e2) = 4.6051….
Standard deviation of the wide, weakly-informative symmetric Normal prior
placed on a relaxable double-penalty smooth’s DoublePenaltyNullspace
selection coordinate when the fit is well-determined.
Write optimized ψ dials back into a measure-jet spec. Returns true when
any dial actually moved. The geometry (centers, masses, band, ℓ, z) is
ψ-FIXED by contract — only the dials change, so frozen-quadrature
rebuilds reproduce the identical penalty layout at the new dials.
Conservative, response-aware anisotropy seed nudge applied before the κ outer
loop. For each anisotropic spatial term it adds a BOUNDED multiple of the
per-axis response-structure contrast (response_aware_axis_contrasts) on top
of the existing geometry seed, so the optimizer starts in the correct basin
instead of at a response-blind near-symmetric point (the #1376 under-recovery
where a signal axis and a nuisance axis with equal coordinate spread seed to
~[0,0]). The nudge is clamped to keep this a perturbation, never a hard
override, so shared aniso Matérn/Duchon fits cannot be destabilized by it.
Replace the 0.0 auto-init length-scale sentinel with a data-derived value
for any Matern / thin-plate kernel reachable from this basis — including the
inner kernel of a by=/factor-smooth wrapper.
Walk a term and, if it is a Matern or thin-plate smooth whose length_scale
was left at the auto sentinel (0.0), overwrite it with
auto_initial_length_scale.
Compute a data-driven initial length scale from the per-axis range of the
feature columns. The heuristic max_range / sqrt(n) puts the kernel on
the wiggly side of REML’s basin so the optimizer can grow it back if the
signal is smooth, but is small enough that high-frequency truths remain
reachable for smoother kernels (ν ≥ 5/2). Clamped to a tiny positive
floor so degenerate constant-input columns can’t produce 0.
Lower bound on the number of sample rows a 1D B-spline smooth needs for a
well-posed penalized REML fit. Used as the per-smooth row floor in
SmoothBasisSpec::min_sample_rows.
Build the EXACT analytic average-derivative design ∂(design row)/∂x_c of a
term collection: the matrix D whose row i is ∂X[i,:]/∂x_{deriv_col},
laid out column-for-column identically to build_term_collection_design, so
D · β = ∂m/∂x_{deriv_col}(x_i) for the fitted coefficient vector β (#1120).
(κ_min, κ_max) outer-optimization window for a constant-curvature term,
derived from the data’s maximum squared chart radius R² so the κ-jets
never leave the κ-stereographic chart. Symmetric about κ = 0:
±CONSTANT_CURVATURE_KAPPA_CHART_FRACTION / R².
A factor-level by= wrapper owns the model-space centering of its inner
smooth: it gates the raw/structurally-constrained basis to the level rows
and then centers that gated block exactly once against the level indicator
(build_parametric_constraint_block_for_term in design_construction).
Leaving the inner B-spline’s default pooled weighted-sum-to-zero active here
would impose two generically-independent constraints — the pooled column
moment m = Σ_h m_h and the per-level moment m_g — so a raw k-column
basis collapses to k-2 columns per level instead of k-1, deleting one
genuine nonconstant spline direction before REML runs (#1427). The group
main effect carries only the constant, so it cannot restore that direction.
Marginal B-spline spec for a factor-smooth block. The marginal always builds
without an identifiability constraint (the per-level replication, not a
sum-to-zero side constraint, provides identifiability against the parametric
block). At predict time the marginal’s knot geometry has already been pinned
into marginal.knotspec by the metadata replay, so the spec is used
verbatim aside from clearing the identifiability transform.
Numeric core of SmoothTerm::wald_unpenalized_dim: the dimension of the
joint null space ∩_k null(S_k) = null(Σ_k S_k) of a term’s local penalty
blocks, with a conservative fallback when a penalty is not materialized as a
full p_local × p_local matrix (e.g. a Kronecker tensor factor).
Build the canonical Matérn operator-penalty triplet (mass / tension /
stiffness) at an explicit effective length scale — i.e. the
σ_geom-compensated, standardized-frame scale the design’s kernel was built
against (NOT the original-coordinate length_scale stored in metadata).
Single source for measure-jet outer-ψ enrollment: the lnτ dial is
undefined in the τ = 0 pseudo-inverse oracle mode (see
build_measure_jet_basis_psi_derivatives), so only a positive ridge
enrolls the dial group. spatial_term_supports_hyper_optimization and
spatial_term_uses_per_axis_psi both defer here so the θ-layout
sources cannot disagree.
Number of multiscale PENALTY dials (excluding the design-moving ℓ):
multiscale (per-scale spectral) mode carries (α, lnτ) = 2 — the order is
either the pinned explicit s or absorbed by the REML-learned per-scale
amplitudes, so it is NOT a dial; single-scale (the default) carries none.
MUST agree with the penalty-coordinate layout of
build_measure_jet_basis_psi_derivatives (its per_level branch always
emits exactly the (α, lnτ) coordinate pair).
ψ dimension of a measure-jet term. The design-moving ℓ dial (when enrolled)
is coordinate 0; the multiscale penalty dials follow. MUST agree with the
coordinate layout of build_measure_jet_basis_psi_derivatives (ℓ first).
Seed ψ from the term’s realized dials, in producer coordinate order: ℓ first
(when enrolled), then the multiscale penalty dials. The ℓ seed is the
realized representer range ln(length_scale) (the resolved spec carries the
concrete auto value after the design build/freeze).
Walk a SmoothBasisSpec tree, re-resolving every column index through
remap. Shared by all predict-time column realignment (see
TermCollectionSpec::remap_feature_columns); kept exhaustive so a newly
added index-bearing variant fails to compile until it is handled here.
Resolve the grouping levels for a factor smooth: replay the frozen level
list when present (predict path), otherwise discover the sorted unique bit
patterns of the factor column (fit path).
Write the optimized κ back into a constant-curvature term spec. Returns
true when κ moved. Centers, ℓ, and the constraint transform z are
κ-FIXED by the basis κ-contract, so only kappa changes.
Single-term κ write-back: the shared validate+apply core, also used directly
on the cached per-trial build spec in the incremental realizer (whose caller
has already change-checked at the collection level and rebuilds regardless
of the moved flag). Mirrors set_single_term_measure_jet_psi_dials.
Single-term dial write-back: the shared match+apply core, also used
directly on the cached per-trial build spec (whose caller has already
change-checked at the collection level and rebuilds regardless of the
moved flag).
Returns true when a spatial term has NO outer optimization axes — i.e.
the user provided an explicit length_scale and the term does not enroll
REML-side per-axis ψ contrasts, so both the scalar κ and any fixed geometry
anisotropy are anchored.
Data-derived ψ seed for a spatial term when the user has not set an
explicit length_scale on its basis spec. Uses the geometric mean of the
data-informed kappa range (i.e., the midpoint of the ψ window).
Compute Σ_k λ_k S_k directly from blockwise penalties, accumulating
into a pre-allocated p_total × p_total output without ever materializing
individual global matrices.