# [R] R vs EViews - serial correlation

Patrick Brandt brandt at unt.edu
Thu Sep 23 20:24:12 CEST 2004

```The issue here is that you have confused an AR(1) process for the
variable of interest with an AR(1) process for its residuals.  The
former is a true AR(1) process, while the latter is really an MA(1)
process, in terms of Box-Jenkins style ARIMA models.

> I met with some problems when dealing with a time series with serial correlation.
>
> FIRST, I generate a series with correlated errors
>
> set.seed(1)
> x=1:50
> y=x+arima.sim(n = 50, list(ar = c(0.47)))

This generates an ARIMA(1,0,0) dataset of 50 observations.  So the d.v.
has an AR(1) process.

>
> SECOND, I estimate three constants (a, b and rho) in the model Y=a+b*X+u, where u=rho*u(-1)+eps
>
> library(nlme)
> gls(y~x,correlation = corAR1(0.5))     # Is it the right procedure?
>
> Coefficients:
> (Intercept)           x
>   0.1410465   1.0023341
>
> Correlation Structure: AR(1)
>  Formula: ~1
>  Parameter estimate(s):
>      Phi
> 0.440594
> Degrees of freedom: 50 total; 48 residual
> Residual standard error: 0.9835158
>

This estimates an AR(1) error process model -- or an ARIMA(0,0,1).  By
the Wold decomposition, the AR(1) dgp we should expect the MA(q) process
to have a longer order than 1.

> THIRD, I do the same procedure with EViews as LS Y C X AR(1) and get
> Y = 0.1375 + 1.0024*X + [AR(1)=0.3915]
>

This fits an AR(1) error process (ARIMA(0,0,1)) if I recall my Eviews
syntax.

> My problem is actually connected with the fitting procedure. As far as I understand
>
> gls(y~x,correlation = corAR1(0.5))\$fit
>
> is obtained through the linear equation 0.1410+1.0023*X while in EViews through the nonlinear equation
>
> Y=rho*Y(-1) + (1-rho)*a+(X-rho*X(-1))*b
>
> where either dynamic or static fitting procedures are applied.
>
>     X       Y    YF_D    YF_S gls.fit
> 1   1  1.1592      NA      NA  1.1434
> 2   2  3.5866  2.1499  2.1499  2.1457
> 3   3  4.1355  3.1478  3.7103  3.1480
> 4   4  3.9125  4.1484  4.5352  4.1504
> 5   5  2.7442  5.1502  5.0578  5.1527
> 6   6  6.0647  6.1523  5.2103  6.1551
> 7   7  6.9855  7.1547  7.1203  7.1574
> .....................................
> 47 47 49.4299 47.2521 47.5288 47.2507
> 48 48 48.7748 48.2545 49.1072 48.2531
> 49 49 48.3200 49.2570 49.4607 49.2554
> 50 50 50.2501 50.2594 49.8926 50.2578

Again, both of the models you fit are NOT the DGP you simulated.

>
> All gls.fit values are on a line, YF_D (D for dynamic) soon begin
> to follow a line and YF_S try to mimic Y.
>

Correct since you are fitting a model of correlated INNOVATIONS, rather
than a model of correlated Y's

> My question is: do R and EViews estimate the same model? If yes, why
> the estimates are different and which of the two (three?) procedures
> is "correct"?
>

If you want to fit the DGP you proposed above, you should use

arima(y, order=c(1,0,0), xreg=x)

Hope that helps.

--
Patrick T. Brandt
Assistant Professor
Department of Political Science
University of North Texas
brandt at unt.edu
http://www.psci.unt.edu/~brandt

```