# [R] R: ts - objects

Marcus Eger marcus.eger at physik.uni-marburg.de
Thu Jul 15 13:18:19 CEST 1999

```Hello,
I faced some difficulties using time series objects.

----------------------------------------------------------------------------
1. Why is the time data changed, when I, e.g., apply sqrt(arrts), but
not
when arrts^0.5 ?
This is my examples time series:
----------------------------------------------------------------------------
> arrts
Time Series:
Start = 3
End = 23
Frequency = 0.2
[,1] [,2]
[1,]    1    6
[2,]    2    7
[3,]    3    8
[4,]    4    9
[5,]    5   10
> time(arrts)
Time Series:
Start = 3
End = 23
Frequency = 0.2
[1]  3  8 13 18 23
>
> time(sqrt(arrts))
Time Series:
Start = c(1, 1)
End = c(5, 1)
Frequency = 1
[1] 1 2 3 4 5
>
> time(arrts^0.5)
Time Series:
Start = 3
End = 23
Frequency = 0.2
[1]  3  8 13 18 23
>

----------------------------------------------------------------------------
2. (At least) boolean indexing with matrices does not seem to work
properly:
----------------------------------------------------------------------------
> arrts[is.finite(arrts)]
Error: subscript (10) out of bounds, should be at most 5
>
> unclass(arrts)[is.finite(arrts)]
[1]  1  2  3  4  5  6  7  8  9 10

----------------------------------------------------------------------------
This problem arose when I tried to plot my time series: > plot(arrts)
It was easy to fix in plot.ts:
----------------------------------------------------------------------------
....
if (is.null(ylim))
ylim <- range(unclass(x)[is.finite(x)])  #by ME, 14-07-99
#    ylim <- range(x[is.finite(x)])
plot.new()
....

-----------------------------------------------------------------------------
3. Another problem had to do with the value of delta and/or start:
-----------------------------------------------------------------------------
> time(ts(c(1,2,3,4),start=3,delta=1.5))
Error: invalid start
>
> time(ts(c(1,2,3,4),start=3,delta=1.4))
Time Series:
Start = 3
End = 7.2
Frequency = 0.7142857
[1] 3.0 4.4 5.8 7.2
>

-----------------------------------------------------------------------------
I´ not sure whether I understood the complete philosphy behind the time
series concept. For me, I just need a structure that supports multiple
repetitions/ensembles of the same random variable/signal and a time
scale.

Thanks for feedback
- Marcus Eger

+-------------------------------------------------------
| Marcus Eger
| Philipps Universitaet Marburg
| Fachbereich Physik AG Neurophysik
| Renthof 7
| 35032 Marburg
| Tel. +49 6421 284169
| Fax  +49 6421 287034
+-------------------------------------------------------
| E-Mail: marcus.eger at physik.uni-marburg.de
| http://www.physik.uni-marburg.de/bio/mitarbei/eger.htm
+-------------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```