MARSS icon indicating copy to clipboard operation
MARSS copied to clipboard

Setting non mxm G throws an error

Open eeholmes opened this issue 5 years ago • 2 comments

library(MARSS)

####################################################################################################
# simple AR(2) model
####################################################################################################
N = 500
y = seq(0, N)
sigma.epsilon = 5
beta.1 = 0.5
beta.2 = -0.3
for (t in seq(2,N)) {
  y[t+1] = beta.1*y[t] + beta.2*y[t-1]+ rnorm(1,0,sigma.epsilon)
}

p = 1
m = 2
Z = matrix(c(1,0), p,m)
B = matrix(list(0), m,m)
B[1, ] = 1
B[,1] = paste(c(rep("theta",m)), seq(m), sep=".")

Q = matrix("sigma.epsilon")
R = matrix(0)

A = matrix(0,p,1)
U = matrix(0,m,1)
G = matrix(c(1,0), m,1)

V0 = diag(c(10,10))
x0 = matrix(rep(0,m))
model.gen=list(Z=Z,A=A,R=R,B=B,U=U,Q=Q, V0=V0, x0=x0, G=G)

kemfit = MARSS(t(y), model=model.gen, silent = TRUE, control=list(maxit=200))

eeholmes avatar Mar 14 '20 07:03 eeholmes

problem is in MARSSkemcheck()

when checking Z, A and B against zeros on diagonal of R and Q, GQt(G) is not used as it should be.

eeholmes avatar Jun 18 '20 23:06 eeholmes

This same bit of code will fail if G has 0s on diagonal

eeholmes avatar Jun 22 '20 23:06 eeholmes