rollingStat       package:PerformanceAnalytics       R Documentation

_w_r_a_p_p_e_r _t_o _a_p_p_l_y _a_n_y _f_u_n_c_t_i_o_n _o_v_e_r _a _r_o_l_l_i_n_g _t_i_m_e _w_i_n_d_o_w

_D_e_s_c_r_i_p_t_i_o_n:

     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.

_U_s_a_g_e:

     rollingStat(R, period = 3, trim = TRUE, FUN, ...)

_A_r_g_u_m_e_n_t_s:

       R: a vector, matrix, data frame, timeSeries or zoo object of
          asset returns 

  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 

    trim: TRUE/FALSE, whether to keep alignment caused by NA's 

     FUN: function to apply over e.g., FUN = "mean" or FUN =
          "Return.cumulative" 

     ...: any other passthru parameters 

_D_e_t_a_i_l_s:

_V_a_l_u_e:

_A_u_t_h_o_r(_s):

     Peter Carl

_R_e_f_e_r_e_n_c_e_s:

_S_e_e _A_l_s_o:

_E_x_a_m_p_l_e_s:

         # 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

