I have a matrix of zoo series. each series is in a column.
x <- as.yearmon(2000 + seq(0, 23)/12)
# 24 months of data, lets make 20 sets of random data
testData <- matrix(rnorm(480),ncol=20)
# make a zoo object and columns will hold the 20 series
TestZoo <- zoo(testData,order.by=x)
# now run lm for just one series.
m <- lm(TestZoo[,1]~time(TestZoo))$coeff[2]
m
time(TestZoo)
0.3443124
m2 <- lm(TestZoo[,2]~time(TestZoo))$coeff[2]
m2
time(TestZoo)
-0.1192866
I've been struggling trying to use apply ( or something equally suitable) to
get a vector of "m" for this entire matrix
without resorting to a loop.
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.