soham chakraborty
2012-Nov-27 10:36 UTC
[R] order.max specification problem in the ar.ols function
Hello I am facing a curious problem.I have a time series data with which i want to fit auto-regressive model of order p, where p runs from 1:9.I am using a for loop which will fit an AR(p) model for each value of p using the *ar.ols* function. I am using the following code for ( p in 1:9){ a=ar.ols (x=data.ts, order.max=p, demean=T, intercept=T) } Specifying the *order.max* to be p, it gives me a fitted AR model of order exactly p, though it may not be the best model. The code works fine except for p=4,5, in which cases it fits an AR (3) model to the data. I don't seem to understand what is the problem.Also is there any alternative way by which i can fit an AR(p) model where p is specified by the user? Any help in this matter will be of immense help. Thank you. Soham Chakraborty -- View this message in context: http://r.789695.n4.nabble.com/order-max-specification-problem-in-the-ar-ols-function-tp4650942.html Sent from the R help mailing list archive at Nabble.com.
Rui Barradas
2012-Nov-27 12:16 UTC
[R] order.max specification problem in the ar.ols function
Hello, Just set argument aic = FALSE. From the help page: |aic| Logical flag. If |TRUE| then the Akaike Information Criterion is used to choose the order of the autoregressive model. If |FALSE|, the model of order |order.max| is fitted. Hope this helps, Rui Barradas Em 27-11-2012 10:36, soham chakraborty escreveu:> Hello > I am facing a curious problem.I have a time series data with which i want to > fit auto-regressive model of order p, where p runs from 1:9.I am using a > for loop which will fit an AR(p) model for each value of p using the > *ar.ols* function. > I am using the following code > for ( p in 1:9){ > a=ar.ols (x=data.ts, order.max=p, demean=T, intercept=T) > } > Specifying the *order.max* to be p, it gives me a fitted AR model of order > exactly p, though it may not be the best model. > The code works fine except for p=4,5, in which cases it fits an AR (3) model > to the data. > I don't seem to understand what is the problem.Also is there any alternative > way by which i can fit an AR(p) model where p is specified by the user? > Any help in this matter will be of immense help. > Thank you. > Soham Chakraborty > > > > -- > View this message in context: http://r.789695.n4.nabble.com/order-max-specification-problem-in-the-ar-ols-function-tp4650942.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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.[[alternative HTML version deleted]]
soham chakraborty
2012-Nov-27 12:34 UTC
[R] order.max specification problem in the ar.ols function
Thank you very much for the advice.It works that way. Soham Chakraborty -- View this message in context: http://r.789695.n4.nabble.com/order-max-specification-problem-in-the-ar-ols-function-tp4650942p4650957.html Sent from the R help mailing list archive at Nabble.com.