Learn R Programming

bda (version 1.2.7-31)

lprde: Density estimation via local polynomial regression

Description

Density estimation via local polynomial regression.

Usage

lprde(x, weights, bandwidth, gridsize=256L, degree=1L,
                  kernel="gaussian", error = NULL, range.x,
                  na.rm=TRUE, binned = FALSE)

Arguments

x
vector of raw data or distinct center information of binned data.
weights
The weights of x. The weight w_i of any observation x_i should be non-negative. If x_i=0, x_i will be removed from the analysis.
bandwidth
the kernel bandwidth smoothing parameter. Larger values of bandwidth make smoother estimates, smaller values of bandwidth make less smooth estimates.
gridsize
The size of grid where the density will be evaluated.
degree
Degree of local polynomial regression.
kernel
Kernel selection. Default: normal
error
Measurement error type. Reserved
na.rm
logical; if TRUE, missing values are removed from x and weights. If FALSE any missing values cause an error.
range.x
vector containing the minimum and maximum values of x at which to compute the estimate. The default is the minimum and maximum data values, extended by the support of the kernel.
binned
Have the data been binned. Default: FALSE.

See Also

histolpr.

Examples

Run this code
ofc0 = rnorm(1000,34.5,1.5)
      ofc = round(ofc0)
      x0 = seq(28,42, length=100)
      f0 = dnorm(x0, 34.5, 1.5)
      plot(x0, f0, type='l', col=2)

      out0 = lprde(ofc0, bandwidth=.25)
      lines(out0, col=4, lty=2)
      
      out1 = lprde(ofc, binned=TRUE,bandwidth=1)
      lines(out1, col=1, lty=2)

Run the code above in your browser using DataLab