incline.PenalizedSpline

class incline.PenalizedSpline(lam=None)[source]

Smoothing spline with a fixed roughness penalty.

Linear, because the penalty is fixed rather than chosen from the data. This is the spline to use when exact standard errors matter; see InterpolatingSpline for the knot-selecting alternative.

Variables:

lam (float | None) – Roughness penalty. Chosen by generalized cross-validation when None – which makes the fit data-dependent and therefore nonlinear.

Parameters:

lam (float | None)

__init__(lam=None)
Parameters:

lam (float | None)

Return type:

None

Methods

__init__([lam])

analytic_operators(axis, order)

State the smoothing and derivative operators directly, if known.

evaluate(axis, y, order)

Fit the penalized spline and differentiate it.

fit(axis, y[, order, se, noise, ...])

Estimate the trend and, optionally, its uncertainty.

native_posterior(axis, y, order, ...)

Uncertainty from the smoother's own probability model.

operators(axis, order)

The smoothing and derivative operators for this configuration.

params()

Report the penalty.

scale_of(axis)

Invert the bandwidth-to-penalty map.

with_scale(scale, axis)

Set the penalty from an equivalent bandwidth.

Attributes

has_native_posterior

is_linear

Linear when the penalty is fixed, not cross-validated.

lam

linear

name

requires_regular_grid

supported_orders

name: ClassVar[str] = 'pspline'
supported_orders: ClassVar[frozenset[int]] = frozenset({0, 1, 2, 3})
lam: float | None = None
property is_linear: bool

Linear when the penalty is fixed, not cross-validated.

evaluate(axis, y, order)[source]

Fit the penalized spline and differentiate it.

Parameters:
  • axis (TimeAxis)

  • y (npt.NDArray[np.float64])

  • order (int)

Return type:

Evaluation

with_scale(scale, axis)[source]

Set the penalty from an equivalent bandwidth.

For a cubic smoothing spline the equivalent kernel width behaves like (lam / n) ** (1/4), so a target width of scale * span implies lam = n * (scale * span) ** 4.

Parameters:
Return type:

Self

scale_of(axis)[source]

Invert the bandwidth-to-penalty map.

Parameters:

axis (TimeAxis)

Return type:

float

params()[source]

Report the penalty.

Return type:

dict[str, Any]