Chapter 3 Data format
The first argument to MARSS()
is your data, aka your response variables or the \(\mathbf{y}\) in your MARSS equation.
MARSS(data, ...)
Your data need to be a matrix with time across the columns (\(n \times T\) matrix). Note, you can pass in a ts
object or a vector (not data frame) and MARSS()
will convert this to a matrix. Here is an example of a data matrix with three observation time series and six time steps. Note that NAs are fine and it is not necessary for all observation time series to have observations at time step \(t\).
Tip: put rownames on your data matrix and those will be used in the output.
\[\begin{equation*} \mathbf{y} = \left[ \begin{array}{ccccccc} 1 & 2 & \text{NA} & \text{NA} & 3.2 & 8\\ 2 & 5 & 3 & \text{NA} & 5.1 & \text{NA}\\ \text{NA} & \text{NA} & \text{NA} & 2.2 & \text{NA} & 7\end{array} \right] \end{equation*}\] where NA denotes a missing value. However, the MARSS functions assume discrete time steps and you will need a value for each time step. Replace any missing time steps with NA.
Why does MARSS require your data in matrix form? Because MARSS will not make any guesses about your intentions. You must be 100% explicit in terms of what model you trying to fit and what you consider to be data
. MARSS models are used in many different fields in different ways. There is no guess that would work for all models. Instead MARSS requires that you write your model in matrix form, and then pass everything in in a format that is one-to-one with that mathematical model. That way MARSS knows exactly what you are trying to do.