[R] Newbie: Acf function

rolf at math.unb.ca rolf at math.unb.ca
Thu Feb 8 16:20:59 CET 2007


Martin Percossi wrote:

> Hi, I would like to use acf.plot on a correlogram that is computed 
> externally. In other words, I would like to "fake out" the acf object. 
> Is this possible?-- any help would be appreciated.

        (a) Note that it's ``plot.acf'' NOT acf.plot.

        (b) This is R --- ***ANYTHING*** is possible.

        (c) Create an object, say ``y'' of class ``acf'',
        having components with the right names.  You could
        build a dummy acf object by

                > dum <- acf(rnorm(100),plot=FALSE)

        and the examine ``dum'' to see what it should consist of.

        (d) Something like:

                y <- list(acf=array(ecc,dim=c(length(ecc),1,1)),
                          type="correlation",
                          n.used=n.ecc,lag=array(0:(length(ecc)-1),
                                                 dim=c(length(ecc),1,1)),
                          series="ecc",snames=NULL)
                class(y) <- "acf"
                plot(y)

        where ``ecc'' is a vector comprising your ``externally
        created correlogram'' and ``n.ecc'' is the length of the series
        from which ecc was created.  Note that the first entry of ecc
        should be 1; it corresponds to lag 0.

                                        cheers,

                                                Rolf Turner
                                                rolf at math.unb.ca



More information about the R-help mailing list