2.1 Model specification

Model specification for MARSS() is one-to-one to your MARSS model written in matrix form. You can mix fixed and estimated parameters, linear constraints, and time-varying parameters. Zeros are allowed on the diagonals of \(\mathbf{Q}\), \(\mathbf{R}\) and \(\boldsymbol{\Lambda}\) to specify partially deterministic systems. There are text shortcuts for common forms of the parameter matrices and there are default forms. See Chapter 4.

Example: a mean-reverting random walk model with three observation time series: \[\begin{gather*} \begin{bmatrix}x_1\\ x_2\end{bmatrix}_t = \begin{bmatrix}b&0\\ 0&b\end{bmatrix} \begin{bmatrix}x_1\\ x_2\end{bmatrix}_{t-1} + \begin{bmatrix}w_1\\ w_2\end{bmatrix}_t, \quad \begin{bmatrix}w_1\\ w_2\end{bmatrix}_t \sim \,\text{MVN}\begin{pmatrix}\begin{bmatrix}0\\0\end{bmatrix},\begin{bmatrix}q_{11}&q_{12}\\ q_{12}&q_{22}\end{bmatrix} \end{pmatrix} \\ \begin{bmatrix}y_1\\y_2\\y_3\end{bmatrix}_t = \begin{bmatrix}1&1\\ 0&1\\ 1&0\end{bmatrix} \begin{bmatrix}x_1\\x_2\end{bmatrix}_t + \begin{bmatrix}v_1\\ v_2\\ v_3\end{bmatrix}_t,\quad \begin{bmatrix}v_1\\ v_2\\ v_3\end{bmatrix}_t \sim MVN\begin{pmatrix}\begin{bmatrix}a_1\\ 0\\ 0\end{bmatrix}, \begin{bmatrix}r_{11}&0&0\\ 0&r&0\\ 0&0&r\end{bmatrix} \end{pmatrix} \\ \begin{bmatrix}x_1\\ x_2\end{bmatrix}_0 \sim \,\text{MVN}\begin{pmatrix}\begin{bmatrix}0\\ 0\end{bmatrix},\begin{bmatrix}1&0\\ 0&1\end{bmatrix} \end{pmatrix} \\ \end{gather*}\]

To fit with MARSS(), we translate this model into equivalent matrices (or arrays if time-varying) . Matrices that combine fixed and estimated values are specified using a list matrix with numerical values for fixed values and character names for the estimated values.

B1 <- matrix(list("b", 0, 0, "b"), 2, 2)
U1 <- matrix(0, 2, 1)
Q1 <- matrix(c("q11", "q12", "q12", "q22"), 2, 2)
Z1 <- matrix(c(1, 0, 1, 1, 1, 0), 3, 2)
A1 <- matrix(list("a1", 0, 0), 3, 1)
R1 <- matrix(list("r11", 0, 0, 0, "r", 0, 0, 0, "r"), 3, 3)
pi1 <- matrix(0, 2, 1)
V1 <- diag(1, 2)
model.list <- list(B = B1, U = U1, Q = Q1, Z = Z1, A = A1, R = R1, 
    x0 = pi1, V0 = V1, tinitx = 0)

If you print these out, you will see the one-to-one correspondence between the model in R and the math version of the model. Matrix names in the model list must be B, U, C, c, Q, Z, A, D, d, R, x0, and V0. In many cases you will use the default values and do not need to specify the parameter for the model list. The tinitx specifies whether the initial state for \(x\) is at \(t=1\) (tinitx=1) or \(t=0\) (tinitx=0).

The MARSS package is designed to handle linear constraints within the parameter matrices. Linear constraint means you can write the elements of the matrix as a linear equation of all the other elements. Time-varying parameters can also be handled.