fit_reml#

SuperLSS.fit_reml(
X: object | EagerFrame,
y: NDArray,
sample_weight: NDArray | None = None,
*,
method: str = 'efs',
max_reml_iter: int = 100,
reml_tol: float = 1e-06,
max_log_step: float = 5.0,
max_lambda: float | None = None,
initial_lambda: float | None = None,
max_inner_iter: int = 100,
inner_tol: float = 1e-07,
lambdas: Mapping[str, float] | None = None,
retain_rows: bool = True,
acceleration: Literal['none', 'multisecant'] = 'none',
acceleration_history: int = 5,
acceleration_max_amplification: float = 8.0,
practical_reml: bool = True,
retain_history_rows: bool = False,
practical_reml_parameter_tol: float = 0.001,
reml_plateau_tol: float = 1e-07,
outer: Literal['efs', 'efs+finish', 'efs+newton'] | None = None,
phase_recorder: FitPhaseRecorder | None = None,
truncation: tuple[object, object] | None = None,
censored: ArrayLike | None = None,
) → SuperLSS#

Fit coefficients and estimate smoothing parameters jointly.

X supplies the declared columns and y supplies the response in the same row order. sample_weight follows the model’s weight_semantics. Declare fixed link-scale additions with offset= on the family predictor helpers. truncation and censored are as in fit(). This method updates the model and returns it.

outer selects the smoothing optimiser. "efs" runs generalised Fellner-Schall updates alone. "efs+finish" runs them to a practical plateau, then finishes with Newton steps on the LAML gradient and Hessian in log lambda, aiming for a stationary point of the LAML over the smoothing-parameter box (Wood, Pya and Saefken 2016, section 3.1). "efs+newton" hands to those Newton steps after a shorter warm-up, on any Fellner-Schall stop. smoothing_convergence_reason_ and smoothing_certified_ report how a fit stopped. The default None runs "efs+finish", except where a family’s curvature jumps (TwoPieceNormalLSS and TwoPieceLogNormalLSS): Newton’s smoothness assumption fails there, so they run "efs" and the endgame is not advised. max_reml_iter bounds the smoothing iterations, Fellner-Schall and Newton together. A default finish that stalls on an exact face is not counted, so such a fit can do up to 16 further iterations of work.

practical_reml stops the Fellner–Schall loop after sustained negligible objective and fitted-parameter movement. Set it to False when strict Fellner–Schall stationarity is required.

Historical coefficient fits retain compact evidence by default, with row arrays kept only for the terminal fit and recent plateau checks. Set retain_history_rows=True to keep every fit’s eta and theta for debugging. retain_rows separately controls final row diagnostics and keeps its existing default.

By default, choose a data-scaled starting penalty for each term. initial_lambda=None adjusts the starting strength of smoothing to the term’s units and the information in the data. Terms with several penalties get a separate start for each. These starts are clipped to the smoothing bounds. Families without expected information, fits with truncated or censored rows, and terms with unresolved numerical rank use 0.1, also clipped to those bounds.

A numeric initial_lambda supplies a common start. Entries in lambdas override it, and fixed penalty policies take precedence over both. The smoothing result retains the numeric starts for replay. Stops can depend on the starting values, so vary them when comparing fits.

With max_lambda=None the search keeps each smoothing parameter between 1e-6 and 1e10 times its term’s information unit (the mean expected information per row of the term’s parameter at the start, rounded to a power of two), with the upper limit never below 1e10. Rescaling the response or the weights moves the optimum and the relative limits together. Families without expected information keep a unit of one. A number caps every smoothing parameter at that value, with the floor at 1e-6, whatever the data’s scale. A fit whose search still pointed past a limit warns, naming the term.