incline.StateSpace¶
- class incline.StateSpace(seasonal_periods=None)[source]¶
Local linear trend, optionally with seasonal and damping.
The slope is a state, so its smoothed variance is a diagonal entry of the smoother covariance and needs no extra machinery. This replaces a hand-rolled Kalman filter and a BFGS call whose inverse Hessian was discarded; statsmodels supplies both the state covariance and the hyperparameter covariance.
- Variables:
seasonal_periods (int | None) – Length of a seasonal cycle, or None.
- Parameters:
seasonal_periods (int | None)
Note
The intervals are conditional on the fitted variances. Those variances were estimated from the same data, and that estimation error is not propagated, so the intervals are somewhat narrow – most visibly on short series.
A correction for it was tried and removed. It scaled the interval by the relative standard error of each variance parameter,
bse / |param|, which is undefined at the boundary – and variances land exactly on zero routinely, whenever a component is not needed. Measured over 40 fits, the median inflation factor was 1e5 and the maximum 3e8, turning a standard error of 0.017 into 4.6e6. A correction that can be eight orders of magnitude wrong is worse than the bias it was meant to remove.There is likewise no damped-trend option. The previous implementation accepted one and forwarded it to statsmodels, which has no such parameter and ignored it, so the setting did nothing.
Methods
__init__([seasonal_periods])analytic_operators(axis, order)State the smoothing and derivative operators directly, if known.
evaluate(axis, y, order)Smoothed level and slope.
fit(axis, y[, order, se, noise, ...])Estimate the trend and, optionally, its uncertainty.
native_posterior(axis, y, order, ...)Standard error of the smoothed slope state.
operators(axis, order)The smoothing and derivative operators for this configuration.
params()Report the model configuration.
scale_of(axis)Nominal scale, since smoothing is chosen by likelihood.
with_scale(scale, axis)No direct scale knob; smoothing follows from the fitted variances.
Attributes
is_linearWhether the derivative is a fixed linear map of the data.
linearrequires_regular_grid- native_posterior(axis, y, order, confidence_level)[source]¶
Standard error of the smoothed slope state.