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?