[R] Simple AR(2)

From: Fabio Ciotola <fabio.ciotola_at_gmail.com>
Date: Fri, 01 Apr 2011 15:34:10 +0100

Hello list,

we are beginners in R and we are trying to fit the following time series:

  *> x <- c(1.89, 2.46, 3.23, 3.95, 4.56, 5.07, 5.62, 6.16, 6.26, 6.56, 6.98, 7.36, 7.53, 7.84, 8.09)*

The reason for choosing the present time series is that the we have previously calculated analytically the autoregressive coefficients using the direct inversion method as *1.1, 0.765, 0.1173*. Since those coefficients fits well our time series, we wanted to learn how to do it in R and check that it would give us the same autoregressive coefficients as the direct inversion method.

So as first step in R we have initially applied the OLS method and obtained the following autoregression coefficients:

*> ar(x, method="ols", order.max=2, demean=FALSE, intercept=TRUE)*

*Call:**ar(x = x, order.max = 2, method = "ols", demean = FALSE,
intercept = TRUE)*

     *1 2 **0.8049 0.0834 *
*Intercept: 1.103 (0.2321) *
*Order selected 2 sigma^2 estimated as 0.009756*

Those are very close to the ones obtained with the direct inversion method so the fitting is good.

Then we tried to apply the other techniques available in R, namely Yule/Walker, Burg, MLE, obtaining different coefficients, which do not give a good fit of the series at all.

*> ar(x, method="yw", order.max=2, demean=FALSE, intercept=TRUE)*

*Call:**ar(x = x, order.max = 2, method = "yw", demean = FALSE,
intercept = TRUE)*

     *1 **0.9305 *

*Order selected 1 sigma^2 estimated as 5.368*

 Please can anybody help us telling how to get a reasonable good fit with YW, Burg and MLE, reporting also the code that needs to be used and commenting the coefficients obtained by comparing those with the ones obtained with OLS.

 Thanks in advance.

        [[alternative HTML version deleted]]

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. Received on Fri 01 Apr 2011 - 15:35:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 01 Apr 2011 - 15:40:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive