# Is a ts of length one a ts? (PR#245)

**Martyn Plummer
**
plummer@iarc.fr

*Wed, 11 Aug 1999 13:52:51 +0200 (CEST)*

On 11-Aug-99 Prof Brian D Ripley wrote:
>* On Wed, 11 Aug 1999, Martyn Plummer wrote:
*>*
*>>* On 10-Aug-99 ripley@stats.ox.ac.uk wrote:
*>>* > Is there any good reason why a time series of length one is not
*>>* > allowed by [.ts (you can certainly create one with ts)?
*>>*
*>>* It certainly has a start and an end value, but what's the
*>>* frequency? If you want the tsp attribute of a time series
*>>* to be well defined, then maybe you should disallow series
*>>* of length 1.
*>*
*>* I think the frequency is perfectly well defined, as that of the series you
*>* subsetted.
*
Is it?
R 0.64.2:
R> x <- ts(1:10)
R> frequency(x)
[1] 1
R> y <- x[c(2,4,6,8,10)]
R> frequency(y)
[1] 0.5
This agrees with the S-PLUS treatment of "regular" time series:
S> x <- rts(1:10)
S> frequency(x)
frequency
1
S> y <- x[c(2,4,6,8,10)]
S> frequency(y)
frequency
0.5
By this logic, the frequency of a single element selected from
a time series is undefined. S-PLUS can get round this problem
because it has the richer time series class "its":
S> z <- x[1]
S> class(z)
[1] "its"
So although z still has a time dimension, it has no frequency.
S-PLUS does allow you to create an "rts" object of length one. There is
a certain logic to this. The time series parameters must satisfy the
equation
frequency * (end - start) = length - 1
For a series of length 1:
frequency * 0 = 0
which is satisfied by any user-specified value of the frequency.
Martyn
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._