Displaying 1 result from an estimated 1 matches for "mdeaths2".
Did you mean:
mdeaths
2003 Aug 08
1
understanding time series objects
...as a matrix
instead of a vector?
# For example:
data(UKLungDeaths)
# If I do
apply(mdeaths,1,cumsum)
# Gives an error as mdeaths is not a matrix but a vector, although when I
look at it :
mdeaths
# the ts object has a matrix like "appearance"
# The only way of doing it I've found is:
mdeaths2<-as.matrix(mdeaths)
dim(mdeaths2)<-c(12,6)
mdeaths2<-apply(mdeaths2,2,cumsum)
mdeaths[]<-mdeaths2
# It is not very efficient to solve the problem of applying a cummulative
sum to each year
### Second, for a multivariate ts:
data(UKLungDeaths)
Multits<-ts.union(mdeaths, fdeaths)
# Wh...