如何估计R中的MARSS包中的G矩阵?

时间:2019-04-02 16:17:29

标签: r

我想估计和/或指定MARSS中的矩阵G。我的模型如下:

X_{t+1} = B*X_{t} + G*W_{t}
Y_{t} = Z*X_{t} + V_{t}

为此,我使用MARSS UserGuide中描述的以下代码:

# Create some random data
M=100;
y1 = rnorm(M);
y2 = rnorm(M);
y3 = rnorm(M);
Y = matrix(c(y1, y2, y3), 
           nrow=3, ncol=100) 

# 1st case: Estimate SS model with restrictions on G
Z=matrix(list("z1","z2",0,0,"z2",3),3,2)
A=matrix(0,3,1)
R=matrix(list(1,0,0,0,1,0,0,0,1),3,3)
G=matrix(list(1,1,1,1),2,2)
B=matrix(list("a","b","c","d"),2,2)
U=matrix(c("u","u"),2,1)
Q=matrix(c(1,0,0,1),2,2)
x0=matrix(c("pi1","pi2"),2,1)
V0=diag(1,2)
model.gen=list(Z=Z,A=A,R=R,B=B,G=G,U=U,Q=Q,x0=x0,V0=V0,tinitx=0)
kemfit = MARSS(Y, model=model.gen)
# 2nd case: Estimate G and other parameters in SS model
Z=matrix(list("z1","z2",0,0,"z2",3),3,2)
A=matrix(0,3,1)
R=matrix(list(1,0,0,0,1,0,0,0,1),3,3)
G=matrix(list("g1","g2","g3","g4"),2,2)
B=matrix(list("a","b","c","d"),2,2)
U=matrix(c("u","u"),2,1)
Q=matrix(c(1,0,0,1),2,2)
x0=matrix(c("pi1","pi2"),2,1)
V0=diag(1,2)
model.gen=list(Z=Z,A=A,R=R,B=B,G=G,U=U,Q=Q,x0=x0,V0=V0,tinitx=0)
kemfit = MARSS(Y, model=model.gen)

在两种情况下,当运行kemfit时,我都会收到以下错误消息:

Error in chol.default(denom) : 
  the leading minor of order 2 is not positive definite

Stopped at iter=1 in MARSSkem at B update. denom is not invertible.
 Type MARSSinfo('denominv') for more info. 
 par, kf, states, iter, loglike are the last values before the error.
 Try control$safe=TRUE which uses a slower but slightly more robust algorithm.
 Use control$trace=1 to generate a more detailed error report. See user guide for insight.

谁能告诉我是怎么回事?

0 个答案:

没有答案