Steps

http://stats.stackexchange.com/questions/8055/how-to-use-dlm-with-kalman-filtering-for-forecasting

  1. What kinds of components describe my series? A trend? Seasonality? Exogenous variables? You will use dlm tools like dlmModPoly to implement these components, using the + operator to join them together into one model.

  2. Create an R subroutine that takes however many parameters are required by this model, creates the components with those parameters, then adds them together and returns the resulting model.

  3. Use dlmMLE to do an search/optimization to find the appropriate parameters (using MLE, which is basically optimization, with the pitfalls that can occur in optimization). dlmMLE repeatedly calls your R subroutine with candidate parameters to create models, then tests them.

  4. Create your final model, using the R subroutine you created plus the parameters you found in step 3.

  5. Filter your data with dlmFilter, then perhaps smooth with dlmSmooth.

  6. If you don’t use dlmModReg or do anything that causes the model to have time-variant parameters, you can use dlmForecast to forecast your series. If you do end up with a time-variant model, you’ll want to fill out your input data with NA’s and let the dlmFilter fill in the NA’s for you (a poor man’s forecast), since dlmForecast does not work with time-varying parameters.

  7. If you want to examine the components individually (say the trend, separately from the seasonal), you’ll need to understand the matrices and what’s in each column, plus understand a bit of how dlm puts them together (order matters!).

Autoregressive distributional lag model (ARDL(1,1) or ADL)

\[y\_t = \alpha + \beta\_0 x\_t + \beta\_i x\_{t-1} + \gamma Y\_{t-1} + \epsilon\]

when $\beta = \gamma = 0$, static regression

AR(1): $\beta_0 = \beta_1 /\gamma$

DLM

Y_t = F_t \theta_t + v_t , v_t \sim N(0, V_t)
\theta_t = G_t \theta_{t-1} + \omega_t, \omega_t \sim N(0, W_t)
  • filtering, s = t
  • state prediction, s > t
  • smoothing (retrospective) , s < t

A common way:

\[Y\_t = Y\_{l, t} + Y\_{s, t} + v\_t\]

linear trend + seasonal (fourier) 3



Published

18 February 2014

Modified

liuminzhao 02/18/2014 14:14:25