Learn R Programming

PerformanceAnalytics (version 0.9.5)

apply.rolling: calculate a function over a rolling window

Description

Creates a results timeseries of a function applied over a rolling window.

Wrapper function for rollapply to hide some of the complexity of managing single-column zoo objects.

Usage

apply.rolling(R, width = 12, FUN = "mean", na.pad = TRUE, ...)

Arguments

R
a vector, matrix, data frame, timeSeries or zoo object of asset returns
FUN
any function that can be evaluated using a single set of returns (e.g., rolling beta won't work, but Return.annualized will)
width
number of periods to apply rolling function window over
na.pad
TRUE/FALSE If TRUE it adds any times that would not otherwise have been in the result with a value of NA. If FALSE those times are dropped.
...
any other passthru parameters

Value

  • A timeseries in a zoo object of the calculation results

concept

rolling window

See Also

apply rollapply