incline.StateSpace

class incline.StateSpace(seasonal_period=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_period (int | None) – Length of a seasonal cycle, or None.

Parameters:

seasonal_period (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.

Ad hoc scaling by a variance parameter’s relative standard error is not used because that ratio is undefined when a fitted variance reaches its boundary at zero.

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.

Sampling must be regular. The state transition advances once per observation, so it cannot represent unequal elapsed times.

__init__(seasonal_period=None)
Parameters:

seasonal_period (int | None)

Return type:

None

Methods

__init__([seasonal_period])

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)

Smoothed level and slope.

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, ...)

Standard error of the smoothed slope state.

operators(axis, derivative_order)

The smoothing and derivative operators for this configuration.

params()

Report the model configuration.

scale_of(axis)

Return None because the model has no direct smoothing scale.

with_scale(scale, axis)

Reject a scale because smoothing follows from fitted variances.

Attributes

has_native_posterior

is_linear

Whether the derivative is a fixed linear map of the data.

linear

name

requires_regular_grid

seasonal_period

supported_orders

uses_noise_for_fit

Whether a supplied noise model can change the point estimate.

name: ClassVar[str] = 'kalman'
has_native_posterior: ClassVar[bool] = True
requires_regular_grid: ClassVar[bool] = True
supported_orders: ClassVar[frozenset[int]] = frozenset({1})
seasonal_period: int | None = None
evaluate(axis, y, derivative_order)[source]

Smoothed level and slope.

Parameters:
  • axis (TimeAxis)

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

  • derivative_order (int)

Return type:

Evaluation

native_posterior(axis, y, derivative_order, confidence_level)[source]

Standard error of the smoothed slope state.

Parameters:
  • axis (TimeAxis)

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

  • derivative_order (int)

  • confidence_level (float)

Return type:

tuple[npt.NDArray[np.float64], None, None]

with_scale(scale, axis)[source]

Reject a scale because smoothing follows from fitted variances.

Parameters:
Return type:

Self

scale_of(axis)[source]

Return None because the model has no direct smoothing scale.

Parameters:

axis (TimeAxis)

Return type:

None

params()[source]

Report the model configuration.

Return type:

dict[str, Any]