# Solved – Difference between intercepts from `lm` (AR(1)) and `arima` functions

I have obtained different values of intercept from autoregressive AR(1) model calculated with `lm` and `arima`, but coefficients before lagged variable are almost exactly the same, intercept for `arima` is `0.1153` and `0.03014` for `lm` why does this difference occurs ?

``> set.seed(123) > ar1 <- arima.sim(n = 1000, list(ar = 0.8, sd = 1)) #simulated dataset > arima(ar1, order=c(1,0,0)) #AR(1) model  Call: arima(x = ar1, order = c(1, 0, 0))  Coefficients:          ar1  intercept       0.7772     0.1153 s.e.  0.0200     0.1418  sigma^2 estimated as 1.006:  log likelihood = -1422.16,  aic = 2850.33 > summary(lm(ar1[-1]~ar1[-1000]))  Call: lm(formula = ar1[-1] ~ ar1[-1000])  Residuals:     Min      1Q  Median      3Q     Max  -2.8835 -0.6563 -0.0029  0.6587  3.1793   Coefficients:             Estimate Std. Error t value Pr(>|t|)     (Intercept)  0.03014    0.03181   0.947    0.344     ar1[-1000]   0.77612    0.02000  38.802   <2e-16 *** --- Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1  Residual standard error: 1.003 on 997 degrees of freedom Multiple R-squared:  0.6016,    Adjusted R-squared:  0.6012  F-statistic:  1506 on 1 and 997 DF,  p-value: < 2.2e-16 ``
Contents

Stationary time series estimation first starts by centering. So the intercept estimation in `arima` is just `mean(ar1)`.

Turning to `lm`. Did you not see that the intercept is not statistically different from 0, as `ar1[-1]` and `ar1[-1000]` have the same mean? That's what stationarity implies.

In summary, `arima` here is doing real estimation for `ar1`, while `lm` is only estimating its auto-correlation. You are doing different things!

If this is still not that clear for you, let's just focus on the `lm` usage in general.

``# true model: y = 0.7 x + 0.5 x <- runif(1000) y <- 0.5 + 0.7 * x + rnorm(1000, 0, 0.05)  # a proper estimation lm(y ~ x)  # now center x and y so they have the same mean: 0 # this only estimates slope x1 <- x - mean(x) y1 <- y - mean(y) lm(y1 ~ x1) ``

Rate this post