UpDownRatios      package:PerformanceAnalytics      R Documentation

_c_a_l_c_u_l_a_t_e _m_e_t_r_i_c_s _o_n _u_p _a_n_d _d_o_w_n _m_a_r_k_e_t_s _f_o_r _t_h_e _b_e_n_c_h_m_a_r_k _a_s_s_e_t

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

     Calculate metrics on how the asset in R performed in up and down
     markets, measured by periods when the benchmark asset was up or
     down.

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

     UpDownRatios(R, Rb, method = "capture", side = "up", ...)

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

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

      Rb: return vector of the benchmark asset 

  method: "capture", "number", or "percentage" to indicate which
          measure to return 

    side: "up" or "down" market statistics 

     ...: any other passthru parameters 

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

     This is a function designed to calculate several related metrics:

     Up (Down) Capture Ratio: this is a measure of an investment's
     compound return when the benchmark was up (down) divided by the
     benchmark's compound return when the benchmark was up (down). The
     greater (lower) the value, the better.

     Up (Down) Number Ratio: similarly, this is a measure of the number
     of periods that the investment was up (down) when the benchmark
     was up (down), divided by the number of periods that the Benchmark
     was up (down).

     Up (Down) Percentage Ratio: this is a measure of the number of
     periods that the investment outperformed the benchmark when the
     benchmark was up (down), divided by the number of periods that the
     benchmark was up (down). Unlike the prior two metrics, in both
     cases a higher value is better.

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

     A data.table of n-period trailing calculations for each column in
     x.

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

     Peter Carl

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

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

     # First we load the data
     data(edhec)
     edhec.length = dim(edhec)[1]
     start = rownames(edhec[1,])
     start
     end = rownames(edhec[edhec.length,])
     edhec.zoo = zoo(edhec, order.by = rownames(edhec))
     sp500.zoo = download.SP500PriceReturns(start = "1996-12-31", end = end)

     # Now we have to align it as "monthly" data
     time(edhec.zoo) = as.yearmon(time(edhec.zoo))
     time(sp500.zoo) = as.yearmon(time(sp500.zoo))
     data.zoo = merge(edhec.zoo[,9,drop=FALSE],sp500.zoo)
     time(data.zoo) = as.Date(time(data.zoo),format="%b %Y")

     # Up Capture:
     UpDownRatios(data.zoo[,1, drop=FALSE], data.zoo[,2, drop=FALSE])
     # Down Capture:
     UpDownRatios(data.zoo[,1, drop=FALSE], data.zoo[,2, drop=FALSE], side="down")

