DLMs are cool, but they are not as simple as, say, ARIMA or other methods. In other methods, you plug in your data and then tweak some parameters of the algorithm, perhaps referring to various diagnostics to guide your settings.
With a DLM, you are creating a state space machine, which consists of several matrices that basically implement something like a Hidden Markov Model. Some packages (
sspir I think, among others) expect that you understand the concept and what the matrices do. I'd highly recommend that you start with the
dlm package, and as @RockScience recommends, walk through the vignette.
dlm you're going to basically take several steps:
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.
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.
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.
Create your final model, using the R subroutine you created plus the parameters you found in step 3.
Filter your data with
dlmFilter, then perhaps smooth with
If you use
dlmModReg or do anything that causes the model to have time-variant parameters, you can't 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.
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!).
There's another package, whose name escapes me, which tries to create a front end that can use several of these packages (including
dlm as the back end). Unfortunately, I've never gotten it to work well, but that might just be me.
I'd really recommend getting a book on DLMs. I got a couple of them and played a lot with
dlm to get to where I am, and I'm not the expert by any means.