I have a need to build a time series and there are a couple of aspects about the time series object that are confusing me. First it seems that ts.union is not doing what I would expect. For example:
x0 <- rep(0,10)
x1 <- rep(1,10)
xt0 <- ts(x0, frequency=10)
xt1 <- ts(x1, frequency=10)
st2 <- ts.union(xt0, xt1)
Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log = log) :
10 y values <= 0 omitted from logarithmic plot
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
4: In xy.coords(x, y, xlabel, ylabel, log) :
5 y values <= 0 omitted from logarithmic plot
I would expect that ts.union would concatenate the time series. I would expect xt2 from above to be a time series from 1:20. If I do
xt2 <- c(xt0, xt1)
xt2
[1] 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1
This seems to get rid of the time series nature of each of the objects.
I can do:
On Thu, 4 Sep 2008, rkevinburton at charter.net wrote:
I have a need to build a time series and there are a couple of aspects about the time series object that are confusing me. First it seems that ts.union is not doing what I would expect. For example:
x0 <- rep(0,10)
x1 <- rep(1,10)
xt0 <- ts(x0, frequency=10)
xt1 <- ts(x1, frequency=10)
st2 <- ts.union(xt0, xt1)
Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log = log) :
10 y values <= 0 omitted from logarithmic plot
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
4: In xy.coords(x, y, xlabel, ylabel, log) :
5 y values <= 0 omitted from logarithmic plot
I would expect that ts.union would concatenate the time series.
You expect wrong. ts.union() is more like cbind() for all combined time
indexes, ts.intersect() for the intersection of time indexes.
I would expect xt2 from above to be a time series from 1:20. If I do
This would never make sense. You have defined both xt0 and xt1 to be time
series starting at 1(1) and ending at 1(10). Why should xt1 be shifted to
start at 2(1) and end at 2(10)?
xt2 <- c(xt0, xt1)
xt2
[1] 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1
This seems to get rid of the time series nature of each of the objects.
I can do: