상태공간모형 LLT(Local Linear Trend)에서 수준(Level, \(\ell_t\))과 기울기(Slope, \(\beta_t\))를 상태로 두고, 칼만 필터(Kalman Filter)로 추세를 추정하는 과정을 상세히 정리한다.


0) 표기

상태벡터와 잡음 정의:

$$ \mathbf{x}_t= \begin{bmatrix} \ell_t \\ \beta_t \end{bmatrix},\quad \mathbf{w}_t= \begin{bmatrix} w_{1,t} \\ w_{2,t} \end{bmatrix},\quad v_t \in \mathbb{R}. $$

1) LLT(Local Linear Trend) 상태공간모형

1.1 상태방정식

$$ \ell_t = \ell_{t-1} + \beta_{t-1} + w_{1,t}, \qquad \beta_t = \beta_{t-1} + w_{2,t}, $$ $$ \mathbf{x}_t = \mathbf{F}\mathbf{x}_{t-1} + \mathbf{w}_t, \quad \mathbf{F}= \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}. $$

1.2 관측방정식

$$ y_t = \ell_t + v_t, \qquad y_t = \mathbf H \mathbf{x}_t + v_t, \quad \mathbf H=\begin{bmatrix}1 & 0\end{bmatrix}. $$

1.3 잡음 가정

$$ \mathbf{w}_t \sim \mathcal{N}(\mathbf{0},\mathbf{Q}), \quad v_t \sim \mathcal{N}(0,R), $$ $$ \mathbf Q= \begin{bmatrix} q_{11} & q_{12} \\ q_{12} & q_{22} \end{bmatrix},\quad R=\sigma_v^2. $$

1.4 초기 상태

$$ \mathbf{x}_{0|0}\sim \mathcal{N}(\mathbf m_0,\mathbf P_0), \quad \mathbf m_0 = \begin{bmatrix}m_{\ell,0}\\ m_{\beta,0}\end{bmatrix}, \quad \mathbf P_0 = \begin{bmatrix} \operatorname{Var}(\ell_0) & \operatorname{Cov}(\ell_0,\beta_0)\\ \operatorname{Cov}(\ell_0,\beta_0) & \operatorname{Var}(\beta_0) \end{bmatrix}. $$

2) 칼만 필터 절차

2.1 예측 단계

상태 예측: $$ \mathbf{x}_{t|t-1} = \mathbf F \mathbf{x}_{t-1|t-1}. $$ 공분산 예측: $$ \mathbf P_{t|t-1} = \mathbf F \mathbf P_{t-1|t-1}\mathbf F^\top + \mathbf Q. $$

2.2 혁신(Innovation)

예측된 관측치: $$ \hat y_{t|t-1} = \mathbf H \mathbf{x}_{t|t-1} = \ell_{t|t-1}. $$ 혁신: $$ \tilde y_t = y_t - \hat y_{t|t-1}. $$ 혁신 공분산: $$ S_t = \mathbf H \mathbf P_{t|t-1}\mathbf H^\top + R = P_{\ell\ell,t|t-1} + R. $$

2.3 칼만 이득

$$ \mathbf K_t = \mathbf P_{t|t-1}\mathbf H^\top S_t^{-1} =\frac{1}{S_t} \begin{bmatrix} P_{\ell\ell,t|t-1}\\ P_{\beta\ell,t|t-1} \end{bmatrix} \equiv \begin{bmatrix} K_{\ell,t}\\ K_{\beta,t} \end{bmatrix}. $$

2.4 상태 갱신

$$ \ell_{t|t}=\ell_{t|t-1}+K_{\ell,t}(y_t-\ell_{t|t-1}), \qquad \beta_{t|t}=\beta_{t|t-1}+K_{\beta,t}(y_t-\ell_{t|t-1}). $$ 공분산 갱신(행렬형): $$ \mathbf P_{t|t} = (\mathbf I - \mathbf K_t \mathbf H)\mathbf P_{t|t-1}. $$ Joseph 안정형: $$ \mathbf P_{t|t} = (\mathbf I - \mathbf K_t\mathbf H)\mathbf P_{t|t-1}(\mathbf I - \mathbf K_t\mathbf H)^\top + \mathbf K_t R \mathbf K_t^\top. $$ 성분 전개: $$ \begin{aligned} P_{\ell\ell,t|t} &= (1-K_{\ell,t})P_{\ell\ell,t|t-1} - K_{\ell,t}P_{\ell\beta,t|t-1}, \\ P_{\ell\beta,t|t} &= (1-K_{\ell,t})P_{\ell\beta,t|t-1} - K_{\ell,t}P_{\beta\beta,t|t-1}, \\ P_{\beta\ell,t|t} &= P_{\ell\beta,t|t}, \\ P_{\beta\beta,t|t} &= P_{\beta\beta,t|t-1} - K_{\beta,t}P_{\beta\ell,t|t-1}. \end{aligned} $$

3) 한 걸음 앞 예측(Forecasting)

$$ \hat y_{t+1|t} = \mathbf H \mathbf{x}_{t+1|t}, \qquad \mathbf{x}_{t+1|t} = \mathbf F \mathbf{x}_{t|t}, $$ $$ \operatorname{Var}(\hat y_{t+1|t}) = \mathbf H \mathbf P_{t+1|t}\mathbf H^\top + R. $$

4) 직관

  • R ↑: 센서 잡음 ↑ → \(K_t \downarrow\) → 관측 덜 신뢰, 추정 매끈
  • Q ↑: 상태 변동 ↑ → \(K_t \uparrow\) → 관측 더 신뢰, 빠른 추적
  • q_{12}\neq 0: 수준–기울기 잡음 상관 고려

5) 행렬 요약

$$ \mathbf F=\begin{bmatrix}1&1\\0&1\end{bmatrix},\quad \mathbf H=\begin{bmatrix}1&0\end{bmatrix},\quad \mathbf Q=\begin{bmatrix}q_{11}&q_{12}\\q_{12}&q_{22}\end{bmatrix},\quad R=\sigma_v^2. $$

6) Pseudocode

입력: y_1..T, F, H, Q, R, 초기 m0, P0
x = m0
P = P0
for t = 1..T:
  # 예측
  x_pred = F x
  P_pred = F P F' + Q

  # 혁신
  y_hat = H x_pred
  y_tilde = y_t - y_hat
  S = H P_pred H' + R

  # 이득
  K = P_pred H' S^{-1}

  # 갱신
  x = x_pred + K y_tilde
  P = (I - K H) P_pred    # Joseph form 가능
end

+ Recent posts