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)

