huberM              package:robustbase              R Documentation

_S_a_f_e (_g_e_n_e_r_a_l_i_z_e_d) _H_u_b_e_r _M-_E_s_t_i_m_a_t_o_r _o_f _L_o_c_a_t_i_o_n

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

     (Generalized) Huber M-estimator of location with MAD scale, being
     sensible also when the scale is zero where 'huber()' returns an
     error.

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

     huberM(x, k = 1.5, weights = NULL, tol = 1e-06,
            mu = if(is.null(weights)) median(x) else wgt.himedian(x, weights),
            s =  if(is.null(weights)) mad(x, center=mu)
                 else wgt.himedian(abs(x - mu), weights),
            warn0scale = getOption("verbose"))

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

       x: numeric vector.

       k: positive factor; the algorithm winsorizes at 'k' standard
          deviations.

 weights: numeric vector of non-negative weights of same length as 'x',
          or 'NULL'.

     tol: convergence tolerance.

      mu: initial location estimator.

       s: scale estimator held constant through the iterations.

warn0scale: logical; if true, and 's' is 0 and 'length(x) > 1', this
          will be warned about.

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

     Note that currently, when non-'NULL' 'weights' are specified, the
     default for initial location 'mu' and scale 's' is 'wgt.himedian',
     where strictly speaking a weighted "non-hi" median should be used
     for consistency. Since 's' is not updated, the results slightly
     differ, see the examples below.

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

     list of location and scale parameters, and number of iterations
     used. 

      mu: location estimate

       s: the 's' argument, typically the 'mad'.

      it: the number of "Huber iterations" used.

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

     Martin Maechler, building on the MASS code mentioned.

_R_e_f_e_r_e_n_c_e_s:

     Huber, P. J. (1981) _Robust Statistics._ Wiley.

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

     'hubers' (and 'huber') in package 'MASS'; 'mad'.

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

     huberM(c(1:9, 1000))
     mad  (c(1:9, 1000))
     mad  (rep(9, 100))
     huberM(rep(9, 100))

     ## When you have "binned" aka replicated observations:
     set.seed(7)
     x <- c(round(rnorm(1000),1), round(rnorm(50, m=10, sd = 10)))
     t.x <- table(x) # -> unique values and multiplicities
     x.uniq <- as.numeric(names(t.x)) ## == sort(unique(x))
     x.mult <- unname(t.x)
     str(Hx  <- huberM(x.uniq, weights = x.mult), digits = 7)
     str(Hx. <- huberM(x, s = Hx$s), digits = 7) ## should be ~= Hx
     stopifnot(all.equal(Hx, Hx.))
     str(Hx2 <- huberM(x), digits = 7)## somewhat different, since 's' differs

