Skip to content

Unexpected behavior with cbind.ts

2 messages · Caio Guimarães Figueiredo, John Kane

#
I got two ts variables (w and y) that I want to cbind into a mts matrix
variable.

w is a simple ts object with some random data, length=40, start = 2005, end
= 2014.75, frequency = 4, class = "ts".

y is a collection of 2 ts, nrow = 40, ncol=2, start = 2005, end = 2014.75,
frequency = 4, class = "mts", "ts", "matrix"

I was expecting that the result of cbind(w,y) to be a mts matrix with 3
columns, 40 rows, same start and frequency as the originals, and finally to
be of class "mts", "ts", "matrix.

What I get is a single ts variable with length = 120, start = 2005 but end
= 2034,75, frequency = 4, class = "ts". This behavior is what i would
expect from ts.union, but not from cbind.

I, unsuccessfully,  tried to replicated this result with different
variables. For example, cbind(ts(c(0,1), ts(matrix(c(2,3,4,5), 2,2))),
returns exactly what I was expecting a ts matrix, with 2 rows and 3 columns.

Anyone has any idea of what is happening? What kind of attribute my
variables could have to imply this behavior? I have the felling that I am
simply calling two different function, but don't know why.

Thank you in advance
#
It would help if you showed us the code you have been using so far plus some sample data (use dput() to produce it) can really help.

See ttp://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

http://adv-r.had.co.nz/Reproducibility.html


John Kane
Kingston ON Canada
____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.