## Dynamic Linear Models with R

Giovanni Petris, Sonia Petrone, Patrizia Campagnoli

Mentioned 1

State space models have gained tremendous popularity in recent years in as disparate fields as engineering, economics, genetics and ecology. After a detailed introduction to general state space models, this book focuses on dynamic linear models, emphasizing their Bayesian analysis. Whenever possible it is shown how to compute estimates and forecasts in closed form; for more complex models, simulation techniques are used. A final chapter covers modern sequential Monte Carlo algorithms. The book illustrates all the fundamental steps needed to use dynamic linear models in practice, using R. Many detailed examples based on real data sets are provided to show how to set up a specific model, estimate its parameters, and use it for forecasting. All the code used in the book is available online. No prior knowledge of Bayesian statistics or time series analysis is required, although familiarity with basic statistics and R is assumed.

I've been using DLM package for modeling my timeseries in state-space format, and then use Kalman Filter to get better 2 step-ahead forecasts.

Even though I've read the vignette and parts of their book, I'm still struggling when it comes to modeling my ARIMA process in state-space format, specifically as the dlm package understands it. My plan is to use auto.arima() to get the best arima model, then represent it as a dlm.

I've seen examples like this.

``````# Estimation of a state space representation of Arima(1,1,1) model and forecast:
level0 <- data.s.g[1]
slope0 <- mean(diff(data.s.g))
buildGap <- function(u) {
trend <- dlmModPoly(dV = 1e-7, dW = exp(u[1 : 2]),
m0 = c(level0, slope0),
C0 = 2 * diag(2))
gap <- dlmModARMA(ar = ARtransPars(u[4]),ma=u[5], sigma2 = exp(u[3]))
return(trend + gap)}
``````

and the dlmModARMA part seems clear. What is baffling me is, what to do if I want to get for example ARIMA(1,3,1); how would I represent that 3 differencing part?

Realated tags