

kde(haerdle)                                 R Documentation

_k_e_r_n_e_l _d_e_n_s_i_t_y _e_s_t_i_m_a_t_i_o_n

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

     kernel density estimation

_U_s_a_g_e_:

     kde(data, kernel, h, points=100)

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

     Required:

    data: vector of data

  kernel: coded  kernel:  =  Uniform, 2 = Triangle,  3 =
          Epanechnikov, 4 = Quartic, 5 = Triweight, 6 =
          Gaussian, 7 = Cosinus

       h: bandwidth

  points: number of points at which to evaluate the density.

_V_a_l_u_e_:

     matrix  with  two columns giving the gridpoint and den-
     sity estimate there.

_N_o_t_e_:

     Evaluates on a grid covering the range of the data.

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

     `Smoothing Techniques with Implementation in S', Wolf-
     gang Haerdle, Springer, 1991

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

     data(buffalo)
     # Figure 2.8
     histogram(buffalo,8,0, ylim=c(0,0.022))
     lines(kde(buffalo,3,8,100))

     data(faithful)
     # Q2.2 (see pp.215-6)
     plot(kde(faithful$eruptions, 4, h=0.1, 80), type="l")
     plot(kde(faithful$eruptions, 4, h=0.3, 80), type="l")
     plot(kde(faithful$eruptions, 4, h=0.6, 80), type="l")

     data(dat.mixed)
     # Figure 2.11
     test.kde<-kde(dat.mixed,6,0.493,100)
     grid<-test.kde[,1]
     true.density<- (0.6*exp(-0.5*(grid+1)^2)
         + 0.4*exp(-0.5*(grid-2)^2))/sqrt(2.0*pi)
     density.mixed<-matrix(c(grid,true.density), length(grid), 2)
     plot(density.mixed,type="n",xlab="dat.mixed",ylab="",cex=0.6)
     lines(test.kde)
     lines(density.mixed, lty=3)

