# Posterior distributions of parameters in a AR(1) model

Consider a AR(1) model with states given by

$x_t=\phi x_{t-1}+a_{t}$, $a_{t}\sim\mathcal{N}(0,\tau^2)$

and the observations given by

$y_t=x_{t}+e_{t}$, $e_{t}\sim\mathcal{N}(0,\sigma^2)$

for $t=1,...,T$. The parameters of this model are $\sigma^2,\tau^2,\phi$. I would like to find the posterior density of the parameters to conduct Gibbs sampling.

I derived the posterior over $\sigma^2$ to be inverse Gamma as $p(\sigma^2|y_{1:T},x_{1:T})=\text{IG}(a,1/b)$ where $a=T/2$ and $b=[(y_{1:T}-x_{1:T})'(y_{1:T}-x_{1:T})]/2$.

Could anyone please help me derive the posterior of the other two parameters? I guess $\tau^2$ is inverse Gamma and $\phi$ is normal(?) TIA.

• I wonder what the relation to the traditional AR(1) model is. The traditional model has only one equation just like your state equation, as if we could observe the state without error. – Richard Hardy Aug 10 '16 at 16:22
• It's framed as a state space model so $x_{1:T}$ are the hidden states and $y_{1:T}$ are the observations. The posterior I am interested is $p(x_{1:T},\theta|y_{1:T})=p(x_{1:T}|\theta,y_{1:T}) p(\theta|y_{1:T})$. I will then perform a Gibbs sampling method over the conditional densities. I sample $x_{1:T}$ from $p(x_{1:T}|\theta,y_{1:T})$ using the Kalman filter. Now I want to sample from $p(\theta|y_{1:T})$. Here $\theta=(\sigma^2,\tau^2,\phi)$. I derived $p(\sigma^2|...)$. I am now trying to derive $p(\tau^2|...)$ and $p(\phi|...)$. – PaulC Aug 10 '16 at 23:45

There are a few things that confuse me by your comments and question. Instead of "I would like to find the posterior density of the parameters to conduct Gibbs sampling" I assume you mean that you would like to conduct Gibbs sampling in order to sample from $$p(x_{1:t},\theta|y_{1:t})$$ and thereby have draws from $$p(\theta|y_{1:t})$$.
Gibbs amounts to alternatively drawing $$\theta^i \sim p(\theta|x_{1:t},y_{1:t})$$ and then $$x_{1:t} \sim p(x_{1:t}|\theta,y_{1:t})$$. Doing this gives you draws from $$p(x_{1:t},\theta|y_{1:t})$$. You can integrate out $$x_{1:t}$$ if you're only interested in $$p(\theta|y_{1:t})$$ (throw away parts of the joint samples). You don't want to deal with $$p(\theta|y_{1:t})$$ at all, really. It's intractable.
The other part you need to draw from $$p(\theta|x_{1:t},y_{1:t}) \propto \pi(\theta)p(y_{1:t},x_{1:t}|\theta)$$. I am assuming it's available in closed form, although I haven't worked it out because you haven’t given the priors, yet.