[R] questions about function arima0

Beáta Darabos bejus79 at gmail.com
Tue May 5 01:29:01 CEST 2009


Hi,

I work on order estimation for autoregressive processes and after some
inconsistencies cropped up I implemented the AIC criterion myself. Its
results do not match the implementation in R and there are a few
things I can not understand even after reading the source code of R.

I used the function called arima0 (with empty "ma" coeficient vector),
and I do not understand how some of the results are calculated:

1. resid

If we denote the estimated order of a time series by k, how does the
function calculate the first k elements of the residual vector? The
rest of the elements match my version, but the first k are not
calculated in my implementation. Calculating them requires some kind
of assumption, but after trying a few possible ones (like using zero
in place of the missing elements ot the average of the time series)
none of them seem to yield the same results as I get from arima0.

2. loglik

The loglikelihood at it's maximum should be a funcion of the estimated
residual variance if the residuals are assumed to be normally
distributed:

-2*loglik = n*log(sigma2)+n*log(2*pi)+n

The $loglik and $sigma2 variables from arima0 do not satisfy that equation.

In my implementation I calculated the residual vector the same way,
but leaving the first k elements, then calculating sigma2 by
sum(resid^2)/(n-k), and at the end I got the loglikelihood through the
equation above.
If I compare the Akaike information criteria I get from my
implementation to the one of R's, I get quite different results.
I performed 100 simulations with time series of length 1000 and the
ratio of correct order selection was different (lower with my
implementation than with R's).

Can you help me to find out what causes the difference?

Best regards,
Beata Darabos




More information about the R-help mailing list