# comparing arima(1,0,0) model to lm produces very similar ar(1) coefficients and very different intercepts

I'm diving into arima models and was trying to repreduce the results of auto regression.

here is a reproducable example:

set.seed(1)
z=arima.sim(n = 101, list(ar = c(0.8)))


when running ar(1) without an intercept

> ceof(arima(z, order = c(1,0,0),include.mean =FALSE))
ar1
0.7622461


when comparing to a linear regression

> coef(lm(z[2:101] ~ z[1:100] + 0))
z[1:100]
0.7586725


which are very similar and can be explained by the different methods used. However when I do this comparison with models that include an intercept, I get again similar results in the ar1 coefficient but very different measures for the intercept. while the intercept that I get in the arima model is the one that makes less sense to me.

> coef(arima(z, order = c(1,0,0)))
ar1 intercept
0.7274511 0.4241322
> coef(lm(z[2:101] ~ z[1:100]))
(Intercept)    z[1:100]
0.1578015   0.7130261


Any ideas on these differencing and in what way the arima procedure is different?

## 2 Answers

The thing that's called an "intercept" in the output of the arima function in R, isn't -- not what you'd normally think of as an intercept, anyway. It's actually the estimate of the $\mu$ parameter:

\begin{eqnarray} (y_t-\mu) &=& \phi_1(y_{t-1}-\mu)+\varepsilon_t\\ &=&\mu + \phi_1 y_{t-1}-\phi_1\mu+\varepsilon_t\\ &=&\mu(1-\phi_1) + \phi_1 y_{t-1}+\varepsilon_t\\ &=&\phi_0 + \phi_1 y_{t-1}+\varepsilon_t \end{eqnarray}

If you calculate $\phi_0=\mu(1-\phi_1)$ for the ARIMA model, it's much closer to that of the conditional least squares model:

 0.4241322 *(1-0.7274511)
[1] 0.1155968


As for why the (now equivalent) coefficients are similar but different, that's essentially down to the arima function including the likelihood for the first observation, which your lm fit conditions on.

I could actually close the question but maybe it would be useful to others:

found the answer in this site

after following the link from this stackoverflow question

• link-only answers are not preferred ... can you edit the question to include essential information from the linked site? Feb 4, 2018 at 3:33