\HeaderA{apply.rolling}{calculate a function over a rolling window}{apply.rolling}
\keyword{ts}{apply.rolling}
\keyword{multivariate}{apply.rolling}
\keyword{distribution}{apply.rolling}
\keyword{models}{apply.rolling}
\begin{Description}\relax
Creates a results timeseries of a function applied over a rolling window.

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

\end{ExampleCode}
\end{Examples}

