QCSunny Lab

State Space & Kalman Filter状态空间与卡尔曼滤波

One value per line in time order. "Local level" models a random walk state; "with drift" adds a constant growth rate; "AR(1)" a stationary persistence.每行一个数值,按时间顺序。“局部水平”为随机游走状态;“带漂移”加入恒定增长率;“AR(1)”为平稳持续性。

A state space model splits a series into an unobserved signal plus noise: y_t = x_t + e_t, with the state x_t evolving as a random walk (local level), a random walk with drift, or a stationary AR(1). The Kalman filter computes the optimal state estimate and the exact likelihood by prediction-error decomposition; the RTS smoother then re-estimates every state using the full sample.

Variances are estimated by maximum likelihood over log-scale parameters, so the optimiser can never propose a negative variance. The forecast standard errors are the filter's own, not a t-distribution bolt-on.

Frequently asked questions

Local level or ARIMA(0,1,1)?

They are the same model family — an exponentially weighted moving average of the past. The state space view adds smoothed states and exact small-sample likelihood; the ARIMA view is easier to extend with seasonality.

What does σ_a ≈ 0 mean?

The state barely moves — the series is essentially constant plus measurement noise, and the best forecast is today's smoothed level, flat.

中文说明

状态空间模型把序列拆成未观测信号加噪声:y_t = x_t + e_t,状态 x_t 按随机游走(局部水平)、带漂移随机游走或平稳 AR(1) 演化。卡尔曼滤波通过预测误差分解给出最优状态估计与精确似然;RTS 平滑器再用全样本重估每个状态。

方差经对数尺度参数极大似然估计,优化器不可能提出负方差。预测标准误来自滤波器本身,而非外挂的 t 分布。

常见问题

局部水平与 ARIMA(0,1,1) 什么关系?

同族模型——历史值的指数加权移动平均。状态空间视角多了平滑状态与精确小样本似然;ARIMA 视角更容易扩展季节项。

σ_a ≈ 0 意味着什么?

状态几乎不动——序列约等于常数加观测噪声,最优预测就是今天的平滑水平,一条平线。