[R] t(xmat)

Jason Turner jasont at indigoindustrial.co.nz
Tue Sep 3 00:59:32 CEST 2002


On Mon, Sep 02, 2002 at 10:11:32PM -0400, Ahmad Abu Hammour wrote:
> I have a matrix and time series "xmat". 

I take it that's a multivariate time series?
class(xmat) would tell you.

> I have no problem executing any matrix functions except 
> t(xmat) which gives the following error message. 

Not clear why you'd want to do this.  A time series is supposed
to have a start, end, and fixed sample time.  Each column is 
a series of observations of one variable.  

The transpose of a multivariate time series changes that to
a series of observations across variables, for a fixed time
for each.  Has its place, but not really in time series analysis.
This *does* make some sense for a data frame, but then
you've already noted that that's an easy conversion.

Further, a time series has a start and an end.  The observations
progress down the columns.  Assuming the transpose had some 
meaning to a time series, transposing it would require a 
modification of the start and end times.

If that's not what you meant, you probably don't need it to 
be a time series.

Note that this *does* work for a sqare time series....

xmat2 <- ts(matrix(rnorm(100),ncol=10))
t(xmat2)

gives an error-free answer (but I still maintain you'd likely
be doing something that wasn't time series analysis for this 
to be useful).

> My question if "xmat" is a matrix why I can not execute this 
> matrix function?? 

It's a matrix whose columns are time series.  It tells you,
correctly, that what you asked made no sense to its internal
time series book-keeping.

> converting the time series and matrix into a data frame solves the problem

Short answer:  Yup.  Same for ts to matrix conversion. ;-)  

Long answer:  By converting to a data frame or matrix, you've told 
R to stop worrying about the data as a time series (sequential 
observations etc., see above).  You've thrown away the start, end, 
deltat, etc.  xmat is now just a block of numbers, and transposes 
make sense once more.  

R stops caring about the time series details (which broke before, but 
that's hardly R's fault), and now treats it as a bunch of collected 
numbers.

If that sounds like a lot of finnicky extras, it is.  It just happens
that those finnicky extras are essential to easy time series 
manipulation.  Doing time series analysis without them is a serious
pain.  Transposes just don't make sense in time series analysis,
is all.

If you don't need the finnicky extras, it sounds like matricies
will suffice.  If you really, really need time series properties
for some functions (ccf() springs to mind), convert them on the 
fly, in the function call; ccf(ts(some.vector),ts(another.vector))

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
64-21-343-545
jasont at indigoindustrial.co.nz
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list