14.6 Fit the model
We specify this one-to-one in R for MARSS()
:
<- function(n) {
makemod <- matrix(list(0), n + 1, n + 1)
B diag(B)[2:(n + 1)] <- paste0("b", 1:n)
1, 1] <- 1
B[<- "zero"
A <- cbind(1, diag(1, n))
Z <- matrix(list(0), n + 1, n + 1)
Q 1, 1] <- 1
Q[diag(Q)[2:(n + 1)] <- paste0("q", 1:n)
<- "zero"
R <- "zero"
U <- "zero"
x0 <- list(B = B, A = A, Z = Z, Q = Q, R = R, U = U,
mod.list x0 = x0, tinitx = 0)
return(mod.list)
}<- makemod(3) mod.list1
Demean the data.
<- dat - apply(dat, 1, mean) %*% matrix(1, 1, TT) dat2
Fit to that
<- MARSS(dat2, model = mod.list1) fit.mod1
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.