locally.weighted.polynomial {SiZer} | R Documentation |
Smoothes the given bivariate data using kernel regression.
Description
Smoothes the given bivariate data using kernel regression.
Usage
locally.weighted.polynomial(
x,
y,
h = NA,
x.grid = NA,
degree = 1,
kernel.type = "Normal"
)
Arguments
x |
Vector of data for the independent variable |
y |
Vector of data for the dependent variable |
h |
The bandwidth for the kernel |
x.grid |
What x-values should the value of the smoother be calculated at. |
degree |
The degree of the polynomial to be fit at each x-value. The default is to fit a linear regression, ie degree=1. |
kernel.type |
What kernel to use. Valid choices are 'Normal', 'Epanechnikov', 'biweight', and 'triweight'. |
Details
The confidence intervals are created using the row-wise method of Hannig and Marron (2006).
Notice that the derivative to be estimated must be less than or equal to the degree of the polynomial initially fit to the data.
If the bandwidth is not given, the Sheather-Jones bandwidth selection method is used.
Value
Returns a LocallyWeightedPolynomial
object that has the following elements:
- data
A structure of the data used to generate the smoothing curve
- h
The bandwidth used to generate the smoothing curve.
- x.grid
The grid of x-values that we have estimated function value and derivative(s) for.
- degrees.freedom
The effective sample size at each grid point
- Beta
A matrix of estimated beta values. The number of rows is degrees+1, while the number of columns is the same as the length of x.grid. Notice that
and so on...
- Beta.var
Matrix of estimated variances for
Beta
. Same structure asBeta
.
Author(s)
Derek Sonderegger
References
Chaudhuri, P., and J. S. Marron. 1999. SiZer for exploration of structures in curves. Journal of the American Statistical Association 94 807-823.
Hannig, J., and J. S. Marron. 2006. Advanced distribution theory for SiZer. Journal of the American Statistical Association 101 484-499.
Sonderegger, D.L., Wang, H., Clements, W.H., and Noon, B.R. 2009. Using SiZer to detect thresholds in ecological data. Frontiers in Ecology and the Environment 7:190-195
See Also
SiZer
, plot.LocallyWeightedPolynomial
,
spm
in package 'SemiPar', loess
, smooth.spline
,
interpSpline
in the splines
package.
Examples
data(Arkansas)
x <- Arkansas$year
y <- Arkansas$sqrt.mayflies
layout(cbind(1,2,3))
model <- locally.weighted.polynomial(x,y)
plot(model, main='Smoothed Function', xlab='Year', ylab='Sqrt.Mayflies')
model2 <- locally.weighted.polynomial(x,y,h=.5)
plot(model2, main='Smoothed Function', xlab='Year', ylab='Sqrt.Mayflies')
model3 <- locally.weighted.polynomial(x,y, degree=1)
plot(model3, derv=1, main='First Derivative', xlab='Year', ylab='1st Derivative')