bandwidth.nrd              package:MASS              R Documentation

_B_a_n_d_w_i_d_t_h _f_o_r _d_e_n_s_i_t_y() _v_i_a _N_o_r_m_a_l _R_e_f_e_r_e_n_c_e _D_i_s_t_r_i_b_u_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     A well-supported rule-of-thumb for choosing the bandwidth of a
     Gaussian kernel density estimator.

_U_s_a_g_e:

     bandwidth.nrd(x)

_A_r_g_u_m_e_n_t_s:

       x: A data vector. 

_V_a_l_u_e:

     A bandwidth on a scale suitable for the 'width' argument of
     'density'.

_R_e_f_e_r_e_n_c_e_s:

     Venables, W. N. and Ripley, B. D. (2002) _Modern Applied
     Statistics with S._ Springer, equation (5.5) on page 130.

_E_x_a_m_p_l_e_s:

     # The function is currently defined as
     function(x)
     {
             r <- quantile(x, c(0.25, 0.75))
             h <- (r[2] - r[1])/1.34
             4 * 1.06 * min(sqrt(var(x)), h) * length(x)^(-1/5)
     }

