Learn R Programming

bda (version 1.2.7-31)

lpreg: Local polynomial regression

Description

Local polynomial regression.

Usage

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

Arguments

x,y
vectors of predictor and response variable.
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

lprde, 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)
      
      bdat = binning(ofc0)
      out3 = lpreg(bdat$x, bdat$y, binned=TRUE, bandwidth=.3)
      lines(out3, col=4, lwd=3)

Run the code above in your browser using DataLab