14.6 Fit the model
We specify this one-to-one in R for MARSS():
makemod <- function(n) {
B <- matrix(list(0), n + 1, n + 1)
diag(B)[2:(n + 1)] <- paste0("b", 1:n)
B[1, 1] <- 1
A <- "zero"
Z <- cbind(1, diag(1, n))
Q <- matrix(list(0), n + 1, n + 1)
Q[1, 1] <- 1
diag(Q)[2:(n + 1)] <- paste0("q", 1:n)
R <- "zero"
U <- "zero"
x0 <- "zero"
mod.list <- list(B = B, A = A, Z = Z, Q = Q, R = R, U = U,
x0 = x0, tinitx = 0)
return(mod.list)
}
mod.list1 <- makemod(3)Demean the data.
dat2 <- dat - apply(dat, 1, mean) %*% matrix(1, 1, TT)Fit to that
fit.mod1 <- MARSS(dat2, model = mod.list1)Success! algorithm run for 15 iterations. abstol and log-log tests passed.
Alert: conv.test.slope.tol is 0.5.
Test with smaller values (<0.1) to ensure convergence.
MARSS fit is
Estimation method: kem
Convergence test: conv.test.slope.tol = 0.5, abstol = 0.001
Algorithm ran 15 (=minit) iterations and convergence was reached.
Log-likelihood: -244.5957
AIC: 501.1914 AICc: 502.2035
Estimate
B.b1 0.790
B.b2 0.406
B.b3 0.905
Q.q1 1.004
Q.q2 23.042
Q.q3 55.892
Initial states (x0) defined at t=0
Standard errors have not been calculated.
Use MARSSparamCIs to compute CIs and bias estimates.