RollingAnalysis          package:fMultivar          R Documentation

_R_o_l_l_i_n_g _A_n_a_l_y_s_i_s

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

     A collection and description of functions  to perform a rolling
     analysis. A rolling  analysis is often required in building
     trading  models. 

     The functions are:

       'rollFun'   Rolling or moving sample statistics,
       'rollMin'   Rolling or moving sample minimum,
       'rollMax'   Rolling or moving sample maximum,
       'rollMean'  Rolling or moving sample mean,
       'rollVar'   Rolling or moving sample variance.

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

     rollFun(x, n, trim = TRUE, na.rm = FALSE, FUN, ...)
     rollMin(x, n = 9, trim = TRUE, na.rm = FALSE) 
     rollMax(x, n = 9, trim = TRUE, na.rm = FALSE)
     rollMean(x, n = 9, trim = TRUE, na.rm = FALSE)
     rollVar(x, n = 9, trim = TRUE, unbiased = TRUE, na.rm = FALSE)

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

     FUN: the rolling function, arguments to this function can be
          passed through the '...' argument. 

       n: an integer specifying the number of periods or  terms to use
          in each rolling/moving sample. 

   na.rm: a logical flag: if TRUE, missing values in x will be removed 
          before computation. The default is FALSE. 

    trim: a logical flag: if TRUE, the first n-1 missing values in  the
          returned object will be removed; if FALSE, they will  be
          saved in the returned object. The default is TRUE. 

unbiased: a logical flag. If TRUE, the unbiased sample variance  will
          be returned. The default is TRUE. 

       x: an univariate 'timeSeries' object or a numeric vector. 

     ...: additional arguments to be passed. 

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

     The functions return a 'timeSeries' object or a numeric vector,
     depending on the argument 'x'.

     'rollMax' returns the rolling sample maximum, 
       'rollMin' returns the rolling sample minimum, 
      'rollMean' returns the rolling sample mean, and 
      'rollVar' returns the biased/unbiased rolling sample variance. 

     Note, that the function 'rollFun' always returns a numeric vector,
     independent of the argument 'x'.

     If you like to operate for 'x' with rectangular objects,  you have
     to call the functions columnwise within a loop.

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

     Diethelm Wuertz for the Rmetrics R-port.

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

     'var'.

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

     ## SOURCE("fMultivar.1C-RollingAnalysis")

     ## Rolling Analysis:
        x = (1:10)^2
        x
        trim =  c(TRUE, TRUE, FALSE, FALSE)
        na.rm = c(TRUE, FALSE, TRUE, FALSE)
        for (i in 1:4) 
          print(rollMin(x, 5, trim[i], na.rm[i]))
        for (i in 1:4) 
          print(rollMax(x, 5, trim[i], na.rm[i]))
        for (i in 1:4) 
          print(rollVar(x, 5, trim[i], unbiased = TRUE, na.rm[i]))
        for (i in 1:4) 
          print(rollVar(x, 5, trim[i], unbiased = FALSE, na.rm[i]))

