[R] "lag1.plot {astsa}" vs. "lag.plot {stats}"

Paul
Mon, 20 Apr 2015 17:20:24 -0000

On Apr 17, 2015, at 7:30 PM, Paul Domaskis <paul.domaskis <at>
gmail.com> wrote:
> I'm following http://www.stat.pitt.edu/stoffer/tsa3/R_toot.htm to
> ramp up on both time series and R.  About 40% of the way down, the
> tutorial uses lag1.plot from astsa and lag.plot from stats.  The
> positioning of the dots look different between the two.  Nothing
> jumps out at me from the help pages that explains why they would be
> different.  Can anyone confirm this difference, and hopefully
> suggest explanations?

Roy Mendelssohn - NOAA Federal <roy.mendelssohn <at> noaa.gov>
writes:
> Not certain which plot you are looking at, but my guess is the
> answer is contained somewhere here:
> http://www.stat.pitt.edu/stoffer/tsa3/Rissues.htm in particular
> perhaps issues 4-5.

Yup, that's it.  What the stats package refers to as lag is
time-advancement.  I assume that this odd definition is due to the
fact that we read from left to right, so a time plot that shifts right
looks like it's racing ahead, even though it is sliding backward along
the time axis.  Heck, it's even infused in the way we refer to
advancing in time, which *often* refers to time progression, i.e.
moving rightward along the time access.

Anyway, the point where this wrinkle occurs in the aforementioned
tutorial is

   lag.plot(dljj, 9, do.lines=FALSE)
   lag1.plot(dljj, 9)  # if you have astsa loaded (not shown)

The following code shows the correction to the use of lag.plot so that
it matches lag1.plot:

   # From tutorial
   lag.plot(dljj, 9, do.lines=FALSE)

   # Correction
   deve.new()
   lag.plot(dljj, set.lags=-1:-9, do.lines=FALSE)

   # astsa's implementation matches above Correctoion
   dev.new()
   lag1.plot(dljj, 9)