locpoly package:KernSmooth R Documentation _E_s_t_i_m_a_t_e _F_u_n_c_t_i_o_n_s _U_s_i_n_g _L_o_c_a_l _P_o_l_y_n_o_m_i_a_l_s _D_e_s_c_r_i_p_t_i_o_n: Estimates a probability density function, regression function or their derivatives using local polynomials. A fast binned implementation over an equally-spaced grid is used. _U_s_a_g_e: locpoly(x, y, drv = 0L, degree, kernel = "normal", bandwidth, gridsize = 401L, bwdisc = 25, range.x, binned = FALSE, truncate = TRUE) _A_r_g_u_m_e_n_t_s: x: vector of x data. Missing values are not accepted. bandwidth: the kernel bandwidth smoothing parameter. It may be a single number or an array having length 'gridsize', representing a bandwidth that varies according to the location of estimation. y: vector of y data. This must be same length as 'x', and missing values are not accepted. drv: order of derivative to be estimated. degree: degree of local polynomial used. Its value must be greater than or equal to the value of 'drv'. The default value is of 'degree' is 'drv' + 1. kernel: '"normal"' - the Gaussian density function. Currently ignored. gridsize: number of equally-spaced grid points over which the function is to be estimated. bwdisc: number of logarithmically-equally-spaced bandwidths on which 'bandwidth' is discretised, to speed up computation. range.x: vector containing the minimum and maximum values of 'x' at which to compute the estimate. binned: logical flag: if 'TRUE', then 'x' and 'y' are taken to be grid counts rather than raw data. truncate: logical flag: if 'TRUE', data with 'x' values outside the range specified by 'range.x' are ignored. _V_a_l_u_e: if 'y' is specified, a local polynomial regression estimate of E[Y|X] (or its derivative) is computed. If 'y' is missing, a local polynomial estimate of the density of 'x' (or its derivative) is computed. a list containing the following components: x: vector of sorted x values at which the estimate was computed. y: vector of smoothed estimates for either the density or the regression at the corresponding 'x'. _D_e_t_a_i_l_s: Local polynomial fitting with a kernel weight is used to estimate either a density, regression function or their derivatives. In the case of density estimation, the data are binned and the local fitting procedure is applied to the bin counts. In either case, binned approximations over an equally-spaced grid is used for fast computation. The bandwidth may be either scalar or a vector of length 'gridsize'. _R_e_f_e_r_e_n_c_e_s: Wand, M. P. and Jones, M. C. (1995). _Kernel Smoothing._ Chapman and Hall, London. _S_e_e _A_l_s_o: 'bkde', 'density', 'dpill', 'ksmooth', 'loess', 'smooth', 'supsmu'. _E_x_a_m_p_l_e_s: data(geyser, package = "MASS") # local linear density estimate x <- geyser$duration est <- locpoly(x, bandwidth = 0.25) plot(est, type = "l") # local linear regression estimate y <- geyser$waiting plot(x, y) fit <- locpoly(x, y, bandwidth = 0.25) lines(fit)