Exogenous variables in dlm package I have been trying to estimate state space models using dlm package in R. The problem is that the model I am estimating requires inclusion of a few exogenous variables. I still can't figure out how to do it.
Does any one know how to add exogenous variables to a state space model in dlm package?
 A: You almost certainly want to do this with a wrapper function and function pointers.
data(endogenous);
data(exogenous);
model <- function(en, ex) {
   # do stuff
   ...
}
# Now you can't call dlm on model because it expects a function of the form f(x)
# so you need to create one of that format
f <- function(x) {
   return( model(x,exogenous) );
}
out <- dlmMLE(endogenous, rep(0,6), f);

The second function (f) is basically a wrapper for your model in the correct form.
A: Most probably those exogeneous variables will take known values which are multiplied by elements of the state vector. Then, you can make them time-varying elements of the observation matrix. There is a utility function which does almost all the work for you: dlmModReg. Type example(dlmModReg) to see how it constructs a state-space model with two "regressors". Also, have a look at the book Dynamic Linear Models with R if you can get hold of a copy.
If you provide a concrete example of model that you want to fit, we might help some more.
