mixle.ppl.statespace module

Linear-Gaussian state-space models for mixle.ppl (Kalman filter + RTS smoother + EM).

A univariate latent state evolves as x_t = phi * x_{t-1} + w_t (w ~ N(0, q)) and is observed as y_t = x_t + v_t (v ~ N(0, r)). LocalLevel() fixes phi = 1 (a random walk + noise / trend smoother); AR1() estimates phi. Fitting is EM: the E-step is the Kalman/RTS smoother, the M-step updates phi, q, r.

class StateSpaceResult(phi, q, r, x0, P0, smoothed, smoothed_var, loglik, *, converged, iterations, objective_trace, termination_reason)[source]

Bases: object

Fitted univariate linear-Gaussian state-space model and smoothed latent path.

The reported loglik is bound to objective_trace[-1] and the converged verdict is bound to termination_reason: a receipt that can state a final objective unrelated to the trace it came from, or a verdict unrelated to the rule that stopped the loop, is not evidence (MXR-080-1897). The smoothed path and its standard deviations are copied and sealed, so neither the caller’s arrays nor a later write through the result can rewrite geometry that was validated at construction.

forecast(h)[source]

Point forecasts h steps ahead from the last smoothed state.

Parameters:

h (int)

summary()[source]

Return fitted dynamics, noise scales, initialization, and log likelihood.

statespace_fit(rv, data, *, how='auto', max_its=200, tol=None, delta=1e-8, missing='error', backend='local', num_workers=None, engine=None, precision=None, print_iter=0, **unknown)[source]

Fit a LocalLevel or AR1 state-space expression by Kalman EM.

Parameters:
  • rv (RandomVariable)

  • how (str)

  • max_its (int)

  • tol (float | None)

  • delta (float)

  • missing (str)

  • backend (str)

  • num_workers (int | None)

  • engine (Any)

  • precision (Any)

  • print_iter (int)

Return type:

RandomVariable