0
$\begingroup$

I am using DLM package in R for estimating state space model While creating DLM object in R I am getting the following error

"Error in all.equal(x\$W, t(x\$W)) && all (eigen(x\$W)$values >= 0) : invalid 'x' type in 'x && y'"

Which suggests that We need to have symmetric W matrix for valid DLM.. In my model it is recommended to have W as a lower triangular Matrix....Any idea about the appropriate way to handle this issue

providing R code for the reference

Build.dlm.corr.dns =function(param) #correlated factors
{
  G= matrix(param[1:9],3,3) #3X3 matrix
  I= diag(3)
  zero= diag(10^1-10,3,3)
  G= rbind(cbind(G,I-G),cbind(zero,I))

  #16 X3 matrix
  W1= matrix(c(param[10],0,0,param[11],param[12],0,param[13],param[14],
               param[15]),3,3,byrow = TRUE) 
  W1= rbind(cbind(W1,zero),cbind(zero,zero))
  #lower diagonal 3*3 matrix for the error in the state equation
  v1= diag(param[16:31]) # 16X16 for the error in the measurement equation
  f=Nelson.Siegel.factor.loadings(lambda=0.06248*12,maturity=Maturity)
  f= cbind(f, matrix(rep(0,48),16,3))
  #We intialize filter with uncoditional mean and varaiance of beta
  M01= c(mean(beta[,1]),mean(beta[,2]),mean(beta[,3]),mean(beta[,1]),mean(beta[,2]),mean(beta[,3])) 

  c01= diag(diag( cov(beta)))
  c01= rbind(cbind(c01,zero),cbind(zero,diag(10^7,3,3)))
  return(list(
    m0 = M01,
    C0 = c01,
    FF = f,
    GG = G,
    V = v1,
    W = W1))
}


param= c(9.888650e-01, -1.585133e-02,  7.503461e-02,  5.223476e-03,  9.370552e-01,  6.029356e-02, -4.766520e-03,
 7.232573e-02,  8.947844e-01,  5.602845e-06, -4.853184e-06,  9.731190e-06,  4.818279e-06, -4.800690e-06,
 7.176372e-05,  8.378143e-07,  1.647291e-07,  4.398396e-07,  7.803341e-07,  3.211860e-07,  2.924895e-07,
3.581549e-07,  3.461191e-07,  2.933340e-07,  4.310282e-07,  3.914763e-07,  6.358530e-07,  9.016495e-07,
1.487223e-06,  1.750846e-06,  1.969300e-06)


mod=Build.dlm.corr.dns(param)
b= dlm(mod)
$\endgroup$
1
$\begingroup$

You indeed need a symmetric $W$; it is the covariance matrix of the process noise, hence needs to be symmetric and non-negative definite. You might parameterize a triangular matrix, say $K$: then you have to construct $W$ as $W = K'K$. This allows you to let parameters in $K$ vary freely and still have $W$ symmetric non-negative definite.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.