ksmooth
Kernel Regression Smoother

Description

Performs scatterplot smoothing using kernel estimates.

Usage

ksmooth(x, y, kernel = c("box", "normal"), bandwidth = 0.5,
    range.x = range(x), n.points = max(100, length(x)), x.points)

Arguments

x a vector of x data. Missing values (NAs) are not accepted.
y a vector of y data. This must be same length as x, and missing values (NAs) are not accepted.
kernel a character string that determines the smoothing kernel. kernel can be one of the following.
"box" a rectangular box (the default).
"normal" the gaussian density function.
bandwidth the kernel bandwidth smoothing parameter. All kernels are scaled so the upper and lower quartiles of the kernel (viewed as a probability density) are +/- 0.25. Larger values of bandwidth make smoother estimates; smaller values of bandwidth make less smooth estimates.
range.x a vector containing the minimum and maximum values of x at which to compute the estimate. If not specified, this argument is set to range(x).
n.points the number of points to smooth in the interval range.x. n.points is set to the length of x.point if x.points is supplied.
x.points a vector specifying where the kernel estimate is computed. If this argument is not specified, it is set to seq.int(range.x[1], range.x[2], length=n.points).
Value
returns a list containing the following components:
x a vector of sorted x values at which the kernel estimate was computed.
y a vector of smoothed estimates for the regression at the corresponding x.
References
Silverman, B. W. 1986. Density Estimation for Statistics and Data Analysis. London, UK: Chapman and Hall.
Watson, G. S. 1966. Smooth regression analysis. Sankha, Ser. A. Volume 26. 359-378.
See Also
density, loess, smooth, supsmu
Examples
# Make up some data:
set.seed(50)
x <- rnorm(100)
eps <- rnorm(100, 0, .1)
y <- sin(x) + eps

# A kernel regression estimate for y on x. ksmxy <- ksmooth(x, y, kern="normal", band=.5, n=50)

Package stats version 6.1.1-7
Package Index