[R] ar function in stats

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Feb 6 09:55:24 CET 2007


On Mon, 5 Feb 2007, Leeds, Mark (IED) wrote:

> I had a couple of questions about the ar function that i was hoping
> someone could answer.
>
[...]

> I call the ar function with aic=TRUE as below so that it picks the order
> of the ar model based on BIC.

It actually does as it says it does (BIC != AIC).

> Yet it returns with no coefficients as the best model.

You mean order 0?

> I do the same call using many, series in a loop ( besides just the one
> above )  and it returns zero coefficients quite a bit of the time.
>
> 1) can this be possible ? because i don't see how zero coefficients
> could be better than one or some ?

Then you don't understand AIC (or BIC), so please study the concepts.
It is not only possible, it happens (including for you).

> 2) also, is there a way to calculate the t-stats for the coefficients
> that come back ?

What are the 't-stats'?  The estimated standard errors are not calculated 
in ar(), if you mean (estimated coefficient)/(estimated se).  There is of 
course *a* way to calculate them!  From the Value section on the help 
page:

asy.var.coef: (univariate case, 'order > 0'.) The asymptotic-theory
           variance matrix of the coefficient estimates.

The question is, what could you validly do with the 't-stats'?

> it would probably be easier for me to just call arima over and over in a
> loop while decreasing the number of lags each time by 1 but
> i am not clever enough in R to do this ? i imagine it requires some form
> of the use of embed but i looked at the code for ar and it
> was pretty beyond me. if anyone happens to have code for doing this type
> of thing, that would be great also. thank you very much.

Hmm, R itself does have examples.  See e.g. ?WWWusage.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list