incline.L1TrendFilter¶
- class incline.L1TrendFilter(penalty=None, penalty_fraction=None, difference_order=2, max_iter=1000, tolerance=1e-08)[source]¶
L1 trend filtering: piecewise-polynomial fit with sparse kinks.
This implements the estimator of Kim et al. (2009), https://doi.org/10.1137/070690274, and its arbitrary-input extension from Tibshirani (2014), https://doi.org/10.1214/13-AOS1189. The convex problem is solved through its box-constrained least-squares dual using SciPy’s
lsq_linear; Incline constructs the grid-aware penalty operator and maps the dual solution back to the fitted trend.The L1 penalty is nonlinear in the data – that is what produces sparse kinks – so uncertainty is bootstrapped.
The penalized difference order and the reported derivative order are separate settings; the previous implementation used one for both.
- Variables:
penalty (float | None) – Absolute penalty on the differences. Larger means fewer kinks. Exactly one of
penaltyandpenalty_fractionis required.penalty_fraction (float | None) – Fraction of the smallest penalty that collapses the fit to a polynomial of degree
difference_order - 1. Exactly one ofpenaltyandpenalty_fractionis required.difference_order (int) – Order of the penalized difference. Two gives a piecewise-linear trend, the usual choice.
max_iter (int) – Bounded least-squares iteration cap.
tolerance (float) – Optimizer convergence tolerance.
- Parameters:
- __init__(penalty=None, penalty_fraction=None, difference_order=2, max_iter=1000, tolerance=1e-08)¶
Methods
__init__([penalty, penalty_fraction, ...])analytic_operators(axis, derivative_order)State the smoothing and derivative operators directly, if known.
bootstrap_uncertainty(estimate, axis, y, ...)Bootstrap a nonlinear smoother, preserving short-range dependence.
evaluate(axis, y, derivative_order)Solve the L1 trend filtering problem, then difference the fit.
evaluate_with_noise(axis, y, ...)Evaluate, allowing an adaptive smoother to use a fitted covariance.
fit(axis, y[, derivative_order, ...])Estimate the trend and, optionally, its uncertainty.
native_posterior(axis, y, derivative_order, ...)Uncertainty from the smoother's own probability model.
operators(axis, derivative_order)The smoothing and derivative operators for this configuration.
params()Report the configured penalty and optimizer settings.
scale_of(axis)Return the configured relative scale when one exists.
with_scale(scale, axis)Set the penalty as a fraction of its saturating value.
Attributes
has_native_posterioris_linearWhether the derivative is a fixed linear map of the data.
linearrequires_regular_gridsupported_ordersuses_noise_for_fitWhether a supplied noise model can change the point estimate.
- evaluate(axis, y, derivative_order)[source]¶
Solve the L1 trend filtering problem, then difference the fit.