## 2.3 Matrix Form 2

In this form, we have the explanatory variables in a matrix on the right of our parameter matrix as in Form 1b but we arrange everything a little differently: $$$\tag{2.7} \begin{bmatrix}stack.loss_1\\stack.loss_2\\stack.loss_3\\stack.loss_4\end{bmatrix} = \begin{bmatrix} \beta&0&0&0\\ 0&\beta&0&0\\ 0&0&\beta&0\\ 0&0&0&\beta \end{bmatrix} \begin{bmatrix}air_1\\air_2\\air_3\\air_4\end{bmatrix} + \begin{bmatrix} \alpha\\ \alpha\\ \alpha\\ \alpha \end{bmatrix} + \begin{bmatrix}e_1\\e_2\\e_3\\e_4\end{bmatrix}$$$ Work through the matrix algebra to make sure you understand why Equation (2.7) is the same as Equation (2.1) for all the $$i$$ data points together.

We will write Form 2 succinctly as $$$\tag{2.8} \mathbf{y}=\mathbf{Z}\mathbf{x}+\mathbf{a}+\mathbf{e}$$$

### 2.3.1 Form 2 with multiple explanatory variables

The $$\mathbf{x}$$ is a column vector of the explanatory variables. If we have more explanatory variables, we add them to the column vector at the bottom. So if we had air flow, water temperature and acid concentration as explanatory variables, $$\mathbf{x}$$ looks like $$$\tag{2.9} \begin{bmatrix}air_1 \\ air_2 \\ air_3 \\ air_4 \\ water_1 \\ water_2 \\ water_3 \\ water_4 \\ acid_1 \\ acid_2 \\ acid_3 \\ acid_4 \end{bmatrix}$$$ Add columns to the $$\mathbf{Z}$$ matrix for each new variable. $$$\begin{bmatrix} \beta_1 & 0 & 0 & 0 & \beta_2 & 0 & 0 & 0 & \beta_3 & 0 & 0 & 0\\ 0 & \beta_1 & 0 & 0 & 0 & \beta_2 & 0 & 0 & 0 & \beta_3 & 0 & 0\\ 0&0&\beta_1&0&0&0&\beta_2&0&0&0&\beta_3&0\\ 0&0&0&\beta_1&0&0&0&\beta_2&0&0&0&\beta_3 \end{bmatrix}$$$ The number of rows of $$\mathbf{Z}$$ is always $$n$$, the number of rows of $$\mathbf{y}$$, because the number of rows on the left and right of the equal sign must match. The number of columns in $$\mathbf{Z}$$ is determined by the size of $$\mathbf{x}$$. Each explanatory variable (like air flow and wind) appears $$n$$ times ($$air_1$$, $$air_2$$, $$\dots$$, $$air_n$$, etc). So if the number of explanatory variables is $$k$$, the number of columns in $$\mathbf{Z}$$ is $$k \times n$$. The $$\mathbf{a}$$ column matrix holds the intercept terms.

### 2.3.2 When does Form 2 arise?

Form 2 is similar to how multivariate time series models are typically written for reading by humans (on a whiteboard or paper). In these models, we see equations like this: $$$\tag{2.10} \begin{bmatrix}y_1\\y_2\\y_3\\y_4\end{bmatrix}_t = \begin{bmatrix} \beta_a&\beta_b\\ \beta_a&0.1\\ \beta_b&\beta_a\\ 0&\beta_a \end{bmatrix} \begin{bmatrix}x_1 \\ x_2 \end{bmatrix}_t + \begin{bmatrix} a\\ a\\ a\\ a \end{bmatrix} + \begin{bmatrix}e_1\\e_2\\e_3\\e_4\end{bmatrix}_t$$$ In this case, $$\mathbf{y}_t$$ is the set of four observations at time $$t$$ and $$\mathbf{x}_t$$ is the set of two explanatory variables at time $$t$$. The $$\mathbf{Z}$$ is showing how we are modeling the effects of $$x_1$$ and $$x_2$$ on the $$y$$s. Notice that the effects are not consistent across the $$x$$ and $$y$$. This model would not be possible to fit with lm() but will be easy to fit with MARSS().