# Simulating state space model with AR(1) dynamics

I asked a question similar to this previously:

https://stats.stackexchange.com/questions/99282/check-that-state-space-model-implemented-correctly

However I think I have a better handle on it now and want to re-ask it:

I simply want to simulate data from a state space model where the state variables follow an AR(1) process (see the code in the first link above).

Given the burn in issues (see link below) I assume it's better to determine empirically how many observations are required until the system reaches its theoretical unconditional variance then ensure that I simulate at least 2 times that amount before using the x(t) generated by the AR(1) process in my state space model.

http://www.mathworks.co.uk/help/econ/simulate-stationary-arma-processes.html

Q1.) If I want to simulate data from my state space model is it necessary to ensure that the AR(1) process is in it's equilibrium state first?

Q2.) From the simulated data I will be able to estimate the observation and state error variances as well as the AR(1) parameters and the unconditional mean and variance of the process (averaged over many sample runs). Assuming these empirical values all match their corresponding theoretical ones, can I then be fully satisfied that the state space model which is based on the AR(1) process has been implemented correctly?

Q3.) How can I estimate what the likely error bounds should be on the parameters that I propose to estimate in Q2?

Baz

• By 'simulating from a state space model' do you mean simply adding additive independent observation error? – gregory_britten Jun 1 '14 at 18:53
• yes I simply draw a set of normal N(0,\sigma_s^2) to add to the state equation to create the time series of the state variables (X(t)). I then take these and calculate the simulated data by multplying the X(t) by a known weighting matrix and adding observation errors N(0,sigma_o^2). I just wanna make sure that the series I have produced is "correct". I will then attempt to fit the data using a max likelihood. – Baz Jun 1 '14 at 19:36
• The goal is to obtain simulated data which can then be used to test different fitting procedures. – Baz Jun 1 '14 at 19:55
• What is the purpose of the weighting matrix? – gregory_britten Jun 1 '14 at 20:14
• The weighting matrix (which is constant) is simply matrix "B" shown on p35 here: pure.au.dk/portal-asb-student/files/48326397/… – Baz Jun 1 '14 at 21:00

## 1 Answer

You are correct in that the AR(1) has a steady-state unconditional distribution that takes some time to equilibrate. The answer to whether you should only estimate parameters from a steady-state AR(1) process is negative, in general. E.g. you can start an AR(1) far away from its equilibrium, never allowing it to reach its steady-state, and still reliably recover the AR(1) parameters and error statistics. However, there ARE cases where it only makes physical sense to talk about the AR(1) at its steady state. For example, in linear stability analysis where the equilibrium deviations are described by an AR(1) model.

That said, you should be clear w.r.t what you are trying to estimate. I suspect you are, at least, trying to estimate the AR(1) matrix elements and the matrix $\textbf{Q}$? Because, conditional on those estimates (assuming all other error statistics are known), the 'process' (which I believe you mean $\textbf{X}_t$) is completely specified by running the Kalman filter.

However, that brings us to the question of the steady-state variance in $\text{Var}(\textbf{X}_t)$, as estimated from the Kalman filter. In a Bayesian context, the variance of $\textbf{X}_t$ early in the series is a function of your prior distribution at $\textbf{x}_0$ (i.e. you have to specify a mean and variance for $\textbf{x}_0$ to begin the filter). Then, after some number of iterations (i.e. after some number of data are used to sequentially update the prior distribution), $\text{Var}(\textbf{X}_t)$ will forget the prior and converge to its steady-state. The amount of time required to forget the prior is related to the relative contribution of process and observation error. If you have low relative observation error, the updating has a strong effect and the memory of the initial conditions is lost quickly; while oppositely, if the observation error is high, the initial conditions persist and steady-state is approached more slowly. There may be analytical results to make this more precise, but I don't know them from the top of my head. In my practise, I often do a suite of simulations to tease these effects apart.