Re: ts in R (again)

About this list Date view Thread view Subject view Author view Other groups

Subject: Re: ts in R (again)
From: Prof Brian D Ripley (ripley@stats.ox.ac.uk)
Date: Tue 17 Aug 1999 - 07:50:52 EST


Message-ID: <Pine.GSO.4.05.9908162225540.29169-100000@auk.stats>

On Tue, 17 Aug 1999, Ross Ihaka wrote:

> On Fri, Aug 13, 1999 at 12:27:13AM +0100, Prof Brian D Ripley wrote:
> > Two other things I would like opinions on:
> >
> > 1) Given multiple series, plot.ts plots them on a single y scale, and
> > plot.mts uses separate plots with a common x. Each has disadvantages.
> > Should we try to switch between the styles depending on the inputs,
> > and if so how?
>
> Genuine query: How do I do I get a simple lagged variable plot like
>
> plot(lag(x), x)
> lines(lowess(lag(x), x))
>
> We don't seem to have any simple way of doing this. Do we need a special
> function for this (with a panel function for effects like lowess/loess)?

As of a few days ago, you can do precisely plot(lag(x), x), as plot.ts has
a `scatterplot' method, and that aligns the time bases. You probably want
plot(lag(x), x, type="p"), but I have not changed the previous default.

The lowess thing is a little more difficult. I think you want

xy <- ts.intersect(z=lag(x), x)
lines(lowess(xy[,1], xy[,2]))

That's the trick: set up all the objects you want, ts.intersect them
and unpick. Some functions like plot.ts and Ops.ts do this for you.

> > 2) I think the current R style of
> >
> > > y <- ts(1:120, end=10-1e-7,frequency=12)
> > > y
> > Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
> > 0 NA 1 2 3 4 5 6 7 8 9 10 11
> > 1 12 13 14 15 16 17 18 19 20 21 22 23
> > 2 24 25 26 27 28 29 30 31 32 33 34 35
> > 3 36 37 38 39 40 41 42 43 44 45 46 47
> > 4 48 49 50 51 52 53 54 55 56 57 58 59
> > 5 60 61 62 63 64 65 66 67 68 69 70 71
> > 6 72 73 74 75 76 77 78 79 80 81 82 83
> > 7 84 85 86 87 88 89 90 91 92 93 94 95
> > 8 96 97 98 99 100 101 102 103 104 105 106 107
> > 9 108 109 110 111 112 113 114 115 116 117 118 119
> > 10 120 NA NA NA NA NA NA NA NA NA NA NA
> >
> > is confusing, not least as it is it impossible to distinguish NAs at the
> > ends from NAs generated by printing. I had a variant in library ts that
> > used format to get blanks. Should I make that the default?
>
> Yes.

Done on Saturday.

> I'm a little bit worried about having libraries overide "base"
> methods. For efficiency reasons it would be better to attach libraries
> after the "base" libraries. That would mean that attempted overrides
> would not work.

There are now no overrides in library(ts), but it was very useful to have
them when testing things out. S has the `first' flag which is normally
false, but can be used to force overrides. I find this useful, not least to
ensure that my library comes in front of a broken one. (Someone out there
with a package on CRAN thinks plot.profile is not the name of a plot method
for profile objects, for example, even though that is in the White Book.)

On the basis of feedback so far, I have altered plot.ts to have a plot.type
flag that defaults to the plot.mts style, and altered print.ts to use
blanks not NAs.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Tue 04 Jan 2000 - 14:16:07 EST