tsmatrix(...)
NA
s) are allowed.
tsp
with the start date, end date, and frequency.)
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).
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.
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