[S] Fitting AR process with non-zero mean (ar.burg)

Christian Keller (ckeller@aicos.com)
Wed, 06 May 1998 14:42:06 +0200

Dear S+ users

Has anyone also stumbled over the problem of fitting an AR
process (using 'ar.burg') without subtracting the mean of
the series first?

## Example: lynx data
acf(log(lynx), type="part")
acf(log(lynx), type="corr")
## --> an AR(2) seems reasonable

As stated in the help files of 'ar', 'ar.yw' and 'ar.burg'

> ...
> The estimation is performed using the sample mean of each
> univariate series as the estimate of the mean. Remember
> that the coefficients in ar are for the series with the
> mean(s) removed.

one would suggest that the mean of the series is estimated and
then removed from the series before calculating the coefficients.
But this is not true as the following example shows.

K <- seq(from=-20, by=2, length=(N <- 21))
a1.burg <- a2.burg <- a1.yw <- a2.yw <- numeric(N)
x0 <- log(lynx) - mean(log(lynx)) # series with mean = 0
for(n in 1:N){ # add a constant to the series x0
## with Burg's algorithm
fit.burg <- ar.burg(x0 + K[n], aic=F, order.max=2)$ar[,,1]
a1.burg[n] <- fit.burg[1]
a2.burg[n] <- fit.burg[2]
## with Yule-Walker
fit.yw <- ar.yw(x0 + K[n], aic=F, order.max=2)$ar[,,1]
a1.yw[n] <- fit.yw[1]
a2.yw[n] <- fit.yw[2]

## plot the AR coefficients vs. K
tsplot(a1.burg, a1.yw, xaxt="n"); axis(1, at=seq(along=K), labels=K)
tsplot(a2.burg, a2.yw, xaxt="n"); axis(1, at=seq(along=K), labels=K)

The coefficients don't change when a constant is added to the
series. But this is because the Yule-Walker equations which are
used to calculate the AR coefficients do not depend on the mean
of the series.

The AR coefficients depend on the constant added to the series
(and therefore on its mean). The coefficients are NOT for the
series with the mean removed, as stated in 'ar.burg'.

At least in help(arima.mle) this is (quite) clear:

> ...
> The model doesn't explicitly allow for a
> non-zero mean of the series, though the estimation is
> invariant to the mean of the data for many of the possible
> models; if you estimate an AR model, you must subtract the
> mean yourself or use the xreg argument in order to get
> sensible estimates.

Correct. But a few lines below in help(arima.mle) (!!)

> Unlike the ar function, the mean of the series will not be
> estimated by arima.mle unless you use the xreg argument.
> arima.mle assumes a zero mean series.

Compare also the example in the manual "Guide to Statistical &
Mathematical Analysis", Version 3.3 for Windows and Unix on page

## as in the manual, without the mean subtracted
ar.burg(log(lynx), aic=F, order.max=2)$ar
, , 1
[1,] 1.5595934
[2,] -0.5711427

## with the mean subtracted 'by hand'
ar.burg(log(lynx)-mean(log(lynx)), aic=F, order.max=2)$ar
, , 1
[1,] 1.3830591
[2,] -0.7461244

## as in the manual with Yule-Walker
ar.yw(log(lynx), aic=F, order.max=2)$ar
, , 1
[1,] 1.3504381
[2,] -0.7200314

Any comments or suggestions?
Christian Keller

I am using
Version 3.4 Release 1 for Sun SPARC, SunOS 5.3 : 1996

Christian Keller Tel: +41 61 686 98 81
AICOS Technologies AG Fax: +41 61 686 98 88
Efringerstrasse 32 email: ckeller@aicos.com
CH-4057 Basel, Switzerland Web: http://www.aicos.com/
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news