weighted.median            package:limma            R Documentation

_W_e_i_g_h_t_e_d _M_e_d_i_a_n

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

     Compute a weighted median of a numeric vector.

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

     weighted.median(x, w, na.rm = FALSE)

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

       x: a numeric vector containing the values whose mean is to be
          computed.

       w: a vector of weights the same length as 'x' giving the weights
          to use for each element of 'x'.

   na.rm: a logical value indicating whether 'NA' values in 'x' should
          be stripped before the computation proceeds.

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

     If 'w' is missing then all elements of 'x' are given the same
     weight.

     Missing values in 'w' are not handled.

     The weighted median is the median of the discrete distribution
     with values given by 'x' and probabilities given by 'w/sum(w)'.

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

     numeric value giving the weighted median

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

     'median', 'weighted.mean'

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

     ## GPA from Siegel 1994
     wt <- c(5,  5,  4,  1)/15
     x <- c(3.7,3.3,3.5,2.8)
     xm <- weighted.median(x,wt)

