wapply               package:multtest               R Documentation

_W_e_i_g_h_t_e_d _v_e_r_s_i_o_n _o_f _t_h_e _a_p_p_l_y _f_u_n_c_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     A function to perform 'apply' on an matrix of data and
     corresponding matrix of weights.

_U_s_a_g_e:

     wapply(X, MARGIN, FUN, W = NULL, ...)

_A_r_g_u_m_e_n_t_s:

       X: A matrix of data.

  MARGIN: A vector giving the subscripts which the function will be
          applied over. 1 indicates rows, 2 indicates columns.

     FUN: The function to be applied. In the case of functions like '+'
          the function name must be quoted.

       W: An optional matrix of weights. When 'W=NULL', the usual
          'apply' function is called.

     ...: optional arguments to 'FUN'.

_D_e_t_a_i_l_s:

     When weights are provided, these are passed to 'FUN' along with
     the data 'X'. For example, if 'FUN=meanX', each data value is
     multiplied by the corresponding weight before the mean is applied.

_V_a_l_u_e:

     If each call to 'FUN' returns a vector of length 'n', then
     'wapply' returns an array of dimension 'c(n, dim(X)[MARGIN])' if
     'n > 1'. If 'n = 1', 'wapply' returns a vector if 'MARGIN' has
     length 1 and an array of dimension 'dim(X)[MARGIN]' otherwise. If
     'n = 0', the result has length 0 but not necessarily the "correct"
     dimension.

     If the calls to 'FUN' return vectors of different lengths,
     'wapply' returns a list of length 'dim(X)[MARGIN]'.

     This function is used in the package 'multtest' to compute
     weighted versions of test statistics. It is called by the function
     'get.Tn' inside the user-level function 'MTP'.

_A_u_t_h_o_r(_s):

     Katherine S. Pollard

_S_e_e _A_l_s_o:

     'get.Tn', 'MTP'

_E_x_a_m_p_l_e_s:

     data<-matrix(rnorm(200),nr=20)
     weights<-matrix(rexp(200,rate=0.1),nr=20)
     wapply(X=data,MARGIN=1,FUN=mean,W=weights)

