hcv                    package:sm                    R Documentation

_C_r_o_s_s-_v_a_l_i_d_a_t_o_r_y _c_h_o_i_c_e _o_f _s_m_o_o_t_h_i_n_g _p_a_r_a_m_e_t_e_r

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

     This function uses the technique of cross-validation to select a
     smoothing  parameter suitable for constructing a density estimate
     or nonparametric  regression curve in one or two dimensions.

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

     hcv(x, y = NA, hstart = NA, hend = NA, ...) 

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

       x: a vector, or two-column matrix of data.  If 'y' is missing
          these are  observations to be used in the construction of a
          density estimate.  If 'y' is present, these are the covariate
          values for a nonparametric regression. 

       y: a vector of response values for nonparametric regression. 

  hstart: the smallest value of the grid points to be used in an
          initial grid search  for the value of the smoothing
          parameter. 

    hend: the largest value of the grid points to be used in an initial
          grid search  for the value of the smoothing parameter. 

     ...: other optional parameters are passed to the 'sm.options'
          function, through a mechanism which limits their effect only
          to this call of the function. Those specifically relevant for
          this function are the following: 'h.weights', 'ngrid',
          'display', 'add'; see the documentation of  'sm.options' for
          their description. 

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

     See Sections 2.4 and 4.5 of the reference below.

     The two-dimensional case uses a smoothing parameter derived from a
     single  value, scaled by the standard deviation of each component.

     This function does not employ a sophisticated algorithm and some
     adjustment of the search parameters may be required for different
     sets of data.  An initial estimate of the value of h which
     minimises the cross-validatory criterion is located from a grid
     search using values which are equally spaced on a log scale
     between 'hstart' and 'hend'.  A quadratic approximation is then
     used to refine this initial estimate.

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

     the value of the smoothing parameter which minimises the
     cross-validation criterion over the selected grid.

_S_i_d_e _E_f_f_e_c_t_s:

     If the minimising value is located at the end of the grid of
     search positions, or if some values of the cross-validatory
     criterion cannot be evaluated, then a warning message is printed. 
     In these circumstances altering the values of 'hstart' and 'hend'
     may improve performance.

_N_o_t_e:

     As from version 2.1 of the package, a similar effect can be
     obtained with the new function 'h.select', via 'h.select(x,
     method="cv")'. Users are encouraged to adopt this route, since
     'hcv' might be not accessible directly in future releases of the
     package.

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

     Bowman, A.W. and Azzalini, A. (1997). _Applied Smoothing
     Techniques for Data Analysis:_  _the Kernel Approach with S-Plus
     Illustrations._ Oxford University Press, Oxford.

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

     'h.select', 'hsj', 'hnorm'

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

     #  Density estimation

     x <- rnorm(50)
     par(mfrow=c(1,2))
     h.cv <- hcv(x, display="lines", ngrid=32)
     sm.density(x, h=hcv(x))
     par(mfrow=c(1,1))

     #  Nonparametric regression

     x <- seq(0, 1, length = 50)
     y <- rnorm(50, sin(2 * pi * x), 0.2)
     par(mfrow=c(1,2))
     h.cv <- hcv(x, y, display="lines", ngrid=32)
     sm.regression(x, y, h=hcv(x, y))
     par(mfrow=c(1,1))

