powered by
Creates a results timeseries of a function applied over a rolling window.
apply.rolling(R, width, trim = TRUE, gap = 12, by = 1, FUN = "mean", ...)
A timeseries in a zoo object of the calculation results
an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns
number of periods to apply rolling function window over
TRUE/FALSE, whether to keep alignment caused by NA's
numeric number of periods from start of series to use to train risk calculation
calculate FUN for trailing width points at every by-th time point.
any function that can be evaluated using a single set of returns (e.g., rolling beta won't work, but Return.annualized will)
Return.annualized
any other passthru parameters
Peter Carl
Wrapper function for rollapply to hide some of the complexity of managing single-column zoo objects.
rollapply
apply rollapply
apply
data(managers) apply.rolling(managers[,1,drop=FALSE], FUN="mean", width=36)
Run the code above in your browser using DataLab