[R] Inverse autocorrelation fonction

From: Jean-Baptiste Lepetit <jb.lepetit_at_wanadoo.fr>
Date: Mon, 16 May 2011 14:13:13 -0700 (PDT)


I've been looking for an IACF() procedure in R for a long time (it's a very convenient function to check for overdifferencing time series), and eventually decided to write my own function. Here's what I came up with :

3 web-pages helped me estimate it :
http://www.xycoon.com/inverse_autocorrelations.htm http://support.sas.com/documentation/cdl/en/etsug/60372/HTML/default/viewer.htm#etsug_arima_sect026.htm
--> How SAS does it

www.jos.nu/Articles/abstract.asp?article=42113 page 116 --> choice of order.max "p" : not too large so that the estimators' std.errors remain reasonably small, but large enough so that for high lags, the inverse autocorrelationq approach zero. One can try 10,20,30,40... it's not recommended to go over N/4

given a "ts" object ts.1 :

artest <- ar(ts.1,aic=F,order.max=30,method="yule-walker") #choice p=30 acfth <- ARMAacf(ar=numeric(0),ma=artest$ar) #compute theoretical acf for an MA, taking the estimated AR coefficients

# Then we plot, using ggplot2 :

library(ggplot2)

base <- data.frame(IACF=as.vector(acfth),Lag=as.numeric(names(acfth))) ci <- 0.95
climy <- qnorm((1 + ci)/2) / sqrt(artest$n.used) ###Computing significativity levels
q2 <- qplot(Lag, IACF, data = base, yend = 0, xend = Lag, geom="bar",stat="identity",fill=I("Darkblue"))+theme_bw()+geom_hline(yintercept=c(-climy,climy),colour="red",linetype="dashed")+opts(title=expression(paste("Inverse autocorrelogram of ",y[t])),plot.title = theme_text(size = 25))+geom_hline(yintercept=0)
q2

Hope this can help somebody

JB Lepetit   

--
View this message in context: http://r.789695.n4.nabble.com/Inverse-autocorrelation-fonction-tp3527467p3527467.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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 Mon 16 May 2011 - 22:42:50 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Tue 17 May 2011 - 14:20:07 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