13.5 Univariate state-space models

At this point, we’ve fit models with observation or process error, but we haven’t tried to estimate both simultaneously. We will do so here, and introduce some new notation to describe the process model and observation model. We use the notation \({x_t}\) to denote the latent state or state of nature (which is unobserved) at time \(t\) and \({y_t}\) to denote the observed data. For introductory purposes, we’ll make the process model autoregressive (similar to our AR(1) model),

\[x_{t} = \phi x_{t-1} + e_{t}, e_{t} \sim N(0,q)\]

For the process model, there are a number of ways to parameterize the first ‘state,’ and we’ll talk about this more in the class, but for the sake of this model, we’ll place a vague weakly informative prior on \(x_0\), \(x_0 \sim N(0, 10)\).Second, we need to construct an observation model linking the estimate unseen states of nature \(x_t\) to the data \(y_t\). For simplicitly, we’ll assume that the observation errors are indepdendent and identically distributed, with no observation component. Mathematically, this model is \[Y_t \sim N(x_t, r)\] In the two above models, we’ll refer to \(q\) as the standard deviation of the process variance and \(r\) as the standard deviation of the observation error variance

We can fit the state-space AR(1) and random walk models using the fit_stan() function:

ss_ar <- atsar::fit_stan(y = Temp, est_drift = FALSE, model_name = "ss_ar")
ss_rw <- atsar::fit_stan(y = Temp, est_drift = FALSE, model_name = "ss_rw")