Search code examples
rzooperformanceanalyticsrollapply

Using apply.rolling function over multiple columns


In zoo package, while using rollapply function, we get an logical option 'by.column = TRUE/FALSE'. If TRUE, FUN is applied to each column separately.

However, in apply.rolling function of PerformanceAnalytics package I don't see any such option. While trying to the following:

require(PerformanceAnalytics)

data(managers)

apply.rolling(managers[,1:10,drop=FALSE], FUN="mean", width=36)

It give me calculation of only first column. Can someone please tell me how can I run this calculation over all the columns in the dataset.


Solution

  • Is there something wrong with just using rollapply()? apply.rolling() is just a wrapper over it.

    rollapply(managers, FUN = mean, width = 36, by.column = TRUE)