rollingFunction     package:PerformanceAnalytics     R Documentation

_w_r_a_p_p_e_r _t_o _a_p_p_l_y _f_u_n_c_t_i_o_n_s _o_v_e_r _a _r_o_l_l_i_n_g _p_e_r_i_o_d

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

     This is a wrapper for providing n-period trailing calculations for
     the data and functions provided.

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

     rollingFunction(R, width, trim = TRUE, na.rm = TRUE, digits = 4, rf = 0, FUN = "mean", ...)

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

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

   width: the number of periods over which a function is to be
          calculated. Use the value zero (0) to roll the statistic from
          inception 

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

   na.rm: TRUE/FALSE Remove NA's from the returns? 

  digits: number of digits to round results to 

      rf: risk free rate, in same period as your returns 

     FUN: function to apply rolling period over 

     ...: any other passthru parameters 

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

     Examples:


     > rollingFunction(gg.ts[,1],n=3,FUN="Return.annualized")
                         Manager
     2002-02-28           0.0306
     2002-03-31           0.0521
     2002-04-30           0.0387
     ...

     >
     rollingFunction(gg.ts[,1],n=3,trim=FALSE,FUN="Return.annualized")
                         Manager
     2001-12-31               NA
     2002-01-31               NA
     2002-02-28           0.0306
     2002-03-31           0.0521
     2002-04-30           0.0387
     ...
     >
     rollingFunction(gg.ts[,1],n=3,trim=FALSE,FUN="SharpeRatio.annualized")
                         Manager
     2001-12-31               NA
     2002-01-31               NA
     2002-02-28           1.5302
     2002-03-31           4.3768
     2002-04-30           6.9640
     ...
     >
     rollingFunction(gg.ts[,1],n=3,trim=FALSE,FUN="SharpeRatio.annualized",rf=.03/12)
                         Manager
     2001-12-31               NA
     2002-01-31               NA
     2002-02-28           0.0298
     2002-03-31           1.8587
     2002-04-30           1.5598 

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

     results over a rolling period

_N_o_t_e:

     Inspired by 'rollFun' written by Diethelm Wurtz.  We've extended
     the idea to all the columns provided.

_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:

     'rollFun'

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

