Dear all,

 

I am currently trying to use the "dlm" package for Kalman filtering.

 

My model is very simple:

 

Y_t = F'_t Theta_t + v_t

Theta_t = G_t Theta_t-1 + w_t

 

v_t ~ N(0,V_t) = N(0,V)

w_t ~ N(0,W_t) = N(0,W)

 

Y_ t is a univariate time series (1x1)

F_t is a vector of factor returns (Kx1)

Theta_t is the state vector (Kx1)

G_t is the identity matrix

 

My first challenge is to get the Maximum Likelihood estimators of V and W
assuming they are time-invariant (homoscedastic) through the dlmMLE
function.

In the example provided in the user guide, F is the Identity matrix
(diag(2)) and I would like to know how to adapt the coding such that F can
vary over time and matches my case study described above.

 

data(NelPlo)

### multivariate local level -- seemingly unrelated time series

buildSu <- function(x) {

Vsd <- exp(x[1:2])

Vcorr <- tanh(x[3])

V <- Vsd %o% Vsd

V[1,2] <- V[2,1] <- V[1,2] * Vcorr

Wsd <- exp(x[4:5])

Wcorr <- tanh(x[6])

W <- Wsd %o% Wsd

W[1,2] <- W[2,1] <- W[1,2] * Wcorr

return(list(

m0 = rep(0,2),

C0 = 1e7 * diag(2),

FF = diag(2),

GG = diag(2),

V = V,

W = W))

}

suMLE <- dlmMLE(NelPlo, rep(0,6), buildSu); suMLE

buildSu(suMLE$par)[c("V","W")]

 

Thanking you in advance for your help,

 

Gerardo Amo


	[[alternative HTML version deleted]]


