7.7 LR with AR(1) errors driven by covariate

We can model a situation where the regression errors are autocorrelated but some of the variance is driven by a covariate. For example, good and bad ‘years’ are driven partially by, say, temperature, which we will model by ct. We will use an autocorrelated ct in the example, but it could be anything. How are autocorrelated errors different? There is memory in the errors. The ct in the past still affects the current error (\(w_t\) in this model).

\[\begin{equation} \begin{gathered} x_{t} = bx_{t-1} + \beta c_t + w_{t}, \text{ } w_t \sim \,\text{N}(0,q) \\ y_{t} = x_{t} + v_t, \text{ } v_t \sim \,\text{N}(0,r) \end{gathered} \tag{7.11} \end{equation}\]

Let’s create some simulated data with this structure:

beta <- 1.1
x0 <- 0
ct <- arima.sim(n = TT, model = list(ar = 0.8), sd = sqrt(1))  # our covariate
ct <- as.vector(ct)
xt <- rep(x0, TT)
for (i in 2:TT) xt[i] <- b * xt[i - 1] + beta * ct[i] + rnorm(1, 
    0, sqrt(q))
yt <- xt + rnorm(TT, 0, sqrt(r))

To fit this with MARSS(), we match up the model to the full MARSS model form:

\[\begin{equation} \begin{gathered} \mathbf{x}_t = \mathbf{B}\mathbf{x}_{t-1} + \mathbf{C}\mathbf{c}_t + \mathbf{w}_t, \text{ } \mathbf{w}_t \sim \,\text{MVN}(0,\mathbf{Q}_t)\\ \mathbf{y}_t = \mathbf{x}_t + \mathbf{v}_t, \text{ } \mathbf{v}_t \sim \,\text{MVN}(0,\mathbf{R}_t) \end{gathered} \end{equation}\]

The model list for MARSS() is:

R <- matrix("r")  # no v_t
C <- matrix("beta")
U <- matrix(0)  # no u
B <- matrix("b")
c <- matrix(ct, nrow = 1)
A <- matrix(0)

Now fit:

mod.list <- list(B = B, U = U, R = R, C = C, c = c, A = A)
fit <- MARSS(yt, model = mod.list)
Success! abstol and log-log tests passed at 56 iterations.
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
Estimation converged in 56 iterations. 
Log-likelihood: -142.9528 
AIC: 295.9055   AICc: 296.5438   
 
       Estimate
R.r       0.764
B.b       0.893
Q.Q       0.107
x0.x0     0.043
C.beta    1.045
Initial states (x0) defined at t=0

Standard errors have not been calculated. 
Use MARSSparamCIs to compute CIs and bias estimates.