backtest-class           package:backtest           R Documentation

_C_l_a_s_s "_b_a_c_k_t_e_s_t"

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

     Contains results from the backtest function.

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

     The primary method for accessing the 'backtest' results is through
     the 'summary' method.  'summary' provides different displays
     depending on the type of 'backtest' object.  These displays are
     shown in the examples section.  Accessor methods such as 'means',
     'counts', 'marginals', 'naCounts', 'turnover', and 'ci' may be
     used to extract other types of information from the object.

     A 'backtest' object with a 'natural' value of TRUE may be graphed
     by calling the 'plot' method.  The default 'plot' method graphs
     return.  The other plots, turnover and cumulative return, must be
     explicitly specified as 'plot(object, type = "turnover")' or
     'plot(object, type = "cumreturn")'.

     The 'backtest' object does not store the data frame used to create
     the 'backtest.'  It only stores the results and the names of the
     vectors used in calculating these results.

     The results of a 'backtest' are stored in a 5-dimensional array,
     'results'.  The 1st dimension contains one value for every element
     of 'ret.var'.  The 2nd dimension contains one value for every
     element of 'in.var'.  The 3rd dimension contains one value for
     every element in '1:buckets[1]', a vector from 1 through the
     number of 'by.var' buckets.  The 4th dimension contains one value
     for every element in '1:buckets[2]', a vector from 1 through the
     number of 'in.var' buckets.  The 5th dimension contains 4
     elements: 'means', 'counts', 'trim.means', and 'NAs'.

_O_b_j_e_c_t_s _f_r_o_m _t_h_e _C_l_a_s_s:

     Objects can be created by calls to the function 'backtest(data,
     in.var, ret.var, ...)'.

_S_l_o_t_s:

     '_i_n._v_a_r': Object of class '"character"' specifying the 'in.var'
          values for this backtest.

     '_r_e_t._v_a_r': Object of class '"character"' containing the 'ret.var'
          values for this backtest.

     '_b_y._v_a_r': Object of class '"character"' containing the 'by.var',
          if specified, for this backtest. 

     '_d_a_t_e._v_a_r': Object of class '"character"' containing the
          'date.var', if specified, for this backtest. 

     '_b_u_c_k_e_t_s': Object of class '"numeric"' containing the number(s) of
          buckets used create quantiles from the 'in.var' and 'by.var'
          values.

     '_r_e_s_u_l_t_s': A 5-dimensional array containing the results of the
          backtest.

     '_r_a_w_s_t_a_t_s': Object of class '"data.frame"' containing some summary
          statistics for this backtest. 

     '_n_a_t_u_r_a_l': Object of class '"logical"' expressing whether or not
          the intervals between observations, as specified by
          'date.var', and returns, as specified by 'ret.var', match. 
          If the interval between dates is one month, the interval
          between returns should also be one month.

_M_e_t_h_o_d_s:

     _s_h_o_w 'signature(object = "backtest")': Prints the variables used
          in this backtest.

     _s_u_m_m_a_r_y 'signature(object = "backtest")': Prints the results of
          the backtest.

     _m_e_a_n_s 'signature(object = "backtest")': Returns a list of
          matrices, with one matrix for each 'in.var', where the value
          of each cell is the mean of the returns for that 'in.var' and
          'by.var' combination.

     _c_o_u_n_t_s 'signature(object = "backtest")': Returns a list of
          matrices, with one matrix for each 'in.var', where the value
          of each cell is the number of observations for that 'in.var'
          and 'by.var' combination.

     _m_a_r_g_i_n_a_l_s 'signature(object = "backtest")': Returns a list of
          matrices, one matrix for each 'in.var', where the value of
          each cell is the number of observations for that 'in.var' and
          'by.var' combination.  Different from 'counts' because the
          marginal sums have been appended to the matrices.

     _n_a_C_o_u_n_t_s 'signature(object = "backtest")': Returns a list of
          matrices, with one matrix for each 'in.var', where the value
          of each cell is the number of NA observations for that
          'in.var' and 'by.var' combination.

     _c_i 'signature(object = "backtest")': Returns a matrix of
          confidence intervals for spreads.


     _t_u_r_n_o_v_e_r 'signature(object = "backtest")': Returns a 'data.frame'
          of the turnovers if the 'backtest' is 'natural'.

     _p_l_o_t 'signature(x = "backtest", y = "missing")': Plots returns,
          cumulative returns, or turnover, when passed a 'type'
          argument of 'return', 'cumreturn', or 'turnover',
          respectively.

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

     Kyle Campbell kyle.w.campbell@williams.edu

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

     'backtest'

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

     data(starmine)
     bt <- backtest(starmine, in.var = "smi", ret.var = "fwd.ret.1m", by.period = FALSE)

     ## Summary for a pooled backtest

     summary(bt)

     ## A natural backtest

     bt <- backtest(starmine, in.var = "smi", ret.var = "fwd.ret.1m",
                    date.var = "date", id.var = "id", natural = TRUE, by.period = FALSE)

     ## Summary for a natural backtest

     summary(bt)

     ## Other access methods

     means(bt)
     counts(bt)
     marginals(bt)
     naCounts(bt)

     ## Plotting methods

     plot(bt, type = "turnover")
     plot(bt, type = "return")
     plot(bt, type = "cumreturn")

