\HeaderA{rollingStat}{wrapper to apply any function over a rolling time window}{rollingStat}
\keyword{ts}{rollingStat}
\keyword{multivariate}{rollingStat}
\keyword{distribution}{rollingStat}
\keyword{models}{rollingStat}
\begin{Description}\relax
Function to apply any time series function over a rolling period, say the last three months.  Pass in the function name as FUN, e.g., FUN = "mean".  Useful for passing in several periods and functions for comparing different series.
\end{Description}
\begin{Usage}
\begin{verbatim}
rollingStat(R, period = 3, trim = TRUE, FUN, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{R}] a vector, matrix, data frame, timeSeries or zoo object of asset returns 
\item[\code{period}] the number of periods over which to calculate the statistic. Setting the period to 0 calculates the statistic "from inception" or using all of the data passed in 
\item[\code{trim}] TRUE/FALSE, whether to keep alignment caused by NA's 
\item[\code{FUN}] function to apply over e.g., FUN = "mean" or FUN = "Return.cumulative" 
\item[\code{...}] any other passthru parameters 
\end{ldescription}
\end{Arguments}
\begin{Author}\relax
Peter Carl
\end{Author}
\begin{Examples}
\begin{ExampleCode}
    # Example includes how to pass in arguements to the function - must be in order:
    # > rollingStat(gg.ts@Data[,1],period=12,FUN="SharpeRatio.annualized",rf=.03/12)
    # [1] 1.476426
    # > rollingStat(gg.ts@Data[,1],period=3,FUN="SharpeRatio.annualized",rf=.03/12)
    # [1] 6.804358
    # > rollingStat(gg.ts@Data[,1],period=3,FUN="SharpeRatio.annualized",rf=0)
    # [1] 8.253612
\end{ExampleCode}
\end{Examples}

