[R] Multivariate apply.rolling()

Cren oscar.soppelsa at bancaakros.it
Fri Jul 13 16:54:16 CEST 2012


# I've read that rollapply, and its wrapper apply.rolling()
# from PerformanceAnalytics package, do not work with multivariate
# time series neither their output can be a multivariate time series.

# Then I was wondering if any other function like those exists, or
# if I need to write my own function to perform multivariate
# time serie rolling analysis.

# Something like this:

# Let 'X' be your multivariate time series:
# output <- matrix(NA, ncol = ncol(X), nrow = nrow(X))
# width <- 199
# for(i in 1:(nrow(output) - width) {
#     data <- X[i:(i + width),]   
#     output[i,] <- function(data)
#}
# rownames(output) <- rownames(as.timeSeries(X))

# ...and this should be a (probably not efficient) way to do it.
# Any better idea?

# Thanks,


--
View this message in context: http://r.789695.n4.nabble.com/Multivariate-apply-rolling-tp4636442.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list