[R] help in ar function
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Nov 27 18:46:35 CET 2007
1) This is fixed in R 2.6.1. In 2.6.0 you can reduce order.max: the
default is longer than your series.
2) Do you really expect to be able to do model fitting on a quarterly
series of length 9? It's quite unrealistic even for a non-seasonal
series. Unsurprisingly, the order selected is 0, and the acf shows no
significant correlations.
A time series of 50 observations would be considered short for selecting
an ar() fit.
On Tue, 27 Nov 2007, cmhcordei at gmail.com wrote:
> Dears Sirs
> During my computational work I encountered unexpected behaviour when calling "ar" function.
> I want to select the order p of the autoregressive approximation by AIC criterion and sometimes an error occurs.
> Example:
> # time series
> x<-ts(c(-0.2052083,-0.3764986,-0.3762448,0.3740089,0.2737568,2.8235722,-1.7783313,0.2728676,-0.3273164),start=c(1978,3),frequency=4,end=c(1980,3))
> # ar function
> res.ar<-ar(x,aic=TRUE,demean=F)
> # call "ar" again and ............
> res.ar<-ar(x,aic=TRUE,demean=F)
> Error in if (order > 0) coefs[order, 1:order] else numeric(0) :
> missing value where TRUE/FALSE needed
> In addition: Warning messages:
> 1: In log(var.pred) : NaNs produced
> 2: In if (order > 0) coefs[order, 1:order] else numeric(0) :
> the condition has length > 1 and only the first element will be used
> For me it is mysterious why sometimes it works and others it does not, perhaps I am doing something wrong and stupid :-(
> If anyone had already had this problem could you please tell me how you have solved it?
> Thank you for your time.
> Best Regards,
> Clara Cordeiro
>> sessionInfo()
> R version 2.6.0 (2007-10-03)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=Portuguese_Portugal.1252;LC_CTYPE=Portuguese_Portugal.1252;LC_MONETARY=Portuguese_Portugal.1252;LC_NUMERIC=C;LC_TIME=Portuguese_Portugal.1252
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] Mcomp_1.07 forecast_1.07 tseries_0.10-12 zoo_1.4-0
> [5] quadprog_1.4-11
>
> loaded via a namespace (and not attached):
> [1] grid_2.6.0 lattice_0.16-5 tools_2.6.0
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
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