# EM for MAP variance of AR(1)

this question is about MAP inference in an AR(1) model (exercise 1.6 from West, M., Time Series: Modeling, Computation and Inference). It's not a homework assignment.

Assume $$n$$ observations were generated from the model

$$y_t = \phi y_{t-1} + \epsilon_t,\ \epsilon_t\sim\mathcal{N}(0, v)$$

where $$y_1$$ (the first observation) is known, i.e. we can use the conditional likelihood $$p(y_{2:n} | y_1, \phi, v)$$ in the following.

# The goal is to compute the mode of $$p(v | y_{1:n})$$

### Priors and posteriors

We put a Gaussian and Inverse Gamma prior on $$\phi$$ and v, respectively and so

$$\phi | v \sim \mathcal{N}(0,v)$$

$$v\sim IG(n_0/2, d_0/2)$$

The posterior distributions are given by

$$\phi | y_{1:n}, v \sim \mathcal{N}(m, vC)$$ $$\qquad(*)$$

$$v| y_{1:n} \sim IG(n^*/2, d^*/2)$$

where $$m=\frac{\sum_{t=2}^n y_{t}y_{t-1}}{\sum_{t=2}^n y_{t-1}+1},\ C=\frac{1}{\sum_{t=2}^n y_{t-1}+1},\ n^*=n+n_0-1,\ d^*=\sum_{t=2}^n y_{t}^2-m+d_0$$

Furthermore, the joint posterior $$(\phi, v | y_{1:n})$$ under the full likelihood $$p(y_{1:n} | \phi, v)$$ is proportional to

$$v^{-n/2+1}(1-\phi^2)^{1/2}\exp\left(-\frac{\sum(y_t-\phi y_{t-1})}{2v}\right)$$ $$\qquad(**)$$

### EM

To find the MAP for $$v$$ we use the EM algorithm. The $$m$$-th E-step comprises of computing $$E^{(m-1)}[\log(\phi,v| y_{1:n})]$$ and so we need to compute the expression

$$\int_{\mathbb{R}}\log p(\phi, v| y_{1:n})p(\phi| v^{m-1}, y_{1:n})d\phi$$

Plugging in the expressions from $$(*), (**)$$ I find that this integral is very hard to compute. Is this really the way to go? How can I make progress?

Thanks for the help!

• A very interesting question. MCMC is used by Bayesians to obtain posterior distributions without directly doing the integral to normalize the density. Have you considered this or does West mention this at all in his text? – Michael R. Chernick Jan 8 '17 at 14:33

Hm, maybe it's just algebra (correct errors if you see one). The expression from above becomes

$\int_{\mathbb{R}}\log p(\phi,v|y_{1:n})p(\phi| v^{m-1}, y_{1:n})d\phi= \mathbb{H}^{m-1}+\underbrace{\int_{\mathbb{R}}\log p(v| y_{1:n})p(\phi| v^{m-1}, y_{1:n})d\phi}_{\log p(v| y_{1:n})\ \cdot\ 1}$

where $\mathbb{H}^{m-1}=\mathbb{E}^{m-1}[\log p(\phi| v, y_{1:n})]=\int_{\mathbb{R}}\log p(\phi| v, y_{1:n})p(\phi| v^{m-1}, y_{1:n})$

is an entropy term. The second term which simplifies to $\log p(v| y_{1:n})$ is the log-density of the Inverse Gamma and so

$\log p(v| y_{1:n})=\frac{n^*}{2}\log\frac{d^*}{2}-\Gamma(\frac{n^*}{2})-(\frac{n^*}{2}+1)\log v - \frac{d^*}{2v}$

Let's attack the entropy term

$\mathbb{H}^{m-1}=\int_{\mathbb{R}}\log p(\phi| v, y_{1:n})p(\phi| v^{m-1}, y_{1:n})=$

$= \underbrace{-\int_{\mathbb{R}}\frac{\log(2\pi vC)}{\sqrt{2\pi vC}}\exp(-\frac{(\phi - m)^2}{2vC})d\phi}_{-1/2 \log(2\pi vC)} - \underbrace{\int_{\mathbb{R}}\frac{1}{\sqrt{2\pi vC}}\frac{(\phi - m)^2}{2vC}\exp(-\frac{(\phi - m)^2}{2vC})d\phi}_{=:\ A}$

With $f(\phi):=\exp(-\frac{(\phi - m)^2}{2vC}) and \eta:=\frac{1}{\sqrt{2\pi vC}}$, the last remaining term requires integration by parts

$A=\int_{\mathbb{R}}\eta\frac{(\phi-m)^2}{2vC}f(\phi)d\phi=-\int_{\mathbb{R}}\eta \frac{\phi-m}{2}\frac{df}{d\phi}d\phi=$

$=-(\int_{\mathbb{R}}\eta f(\phi)\frac{\phi-m}{2}-\underbrace{\int_{\mathbb{R}}\eta\frac{m}{2}f(\phi)d\phi)}_{m/2}$

$=-\frac{vC}{2}\int_{\mathbb{R}}\eta \frac{\phi-m}{vC}f(\phi)d\phi+\frac{m}{2} = \frac{m-vC}{2}$