Create Matrix with Time Series as Columns

DESCRIPTION:
Binds several time series together into a single multivariate time series. The times of the series are aligned as closely as possible.

USAGE:
tsmatrix(...)

REQUIRED ARGUMENTS:
...:
any number of arguments, interpreted as univariate or multivariate time series to form columns of the resulting matrix. All series must have the same frequency. Missing values (NAs) are allowed.

VALUE:
a multivariate time series (a matrix with one or more columns for each argument and an attribute named tsp with the start date, end date, and frequency.)

DETAILS:
The time window for the matrix is the intersection of the time windows for the arguments (i.e., the maximum of the start dates and the minimum of the end dates).

The resulting matrix has a dimnames attribute. If an argument was given a name in the function call, then the corresponding column has that name; if the argument was itself a matrix, then its name is expanded with digits denoting its respective columns. If the argument is a matrix which has a dimnames attribute, then these are used for the corresponding column names.

Multivariate time series are printed by default like a matrix with the tsp attribute printed last. Calling print.ts directly provides an alternative.

Unlike tsmatrix, the function cbind, which also allows vectors or matrices as arguments, makes no effort to make time parameters consistent. Frequently, the two functions can be used together (see the example section).


NOTE:
Time series created by ts have been superseded by the classed time series created by rts, cts, and its. You can coerce a old-style time series to a new with as.rts. The two functions ts.union and ts.intersect replace tsmatrix for the new time series.

SEE ALSO:
cbind , ts , print.ts .

EXAMPLES:
tsmatrix(x, lag(x), diff(x)) #x, lag-1 of x and first diffs
cbind(tsmatrix(x, lag(x)), 1) #two series, column of 1s

yx <- tsmatrix(EMP = employment, GNP = gnp, LGNP = lag(gnp), ...) yx.df <- data.frame(yx) lm(yx.df) # regression with x and y times aligned