locpol | R Documentation |
Formula interface for the local polynomial estimation.
locpol(formula,data,weig=rep(1,nrow(data)),bw=NULL,kernel=EpaK,deg=1, xeval=NULL,xevalLen=100) confInterval(x) ## S3 method for class 'locpol' residuals(object,...) ## S3 method for class 'locpol' fitted(object,deg=0,...) ## S3 method for class 'locpol' summary(object,...) ## S3 method for class 'locpol' print(x,...) ## S3 method for class 'locpol' plot(x,...)
formula |
formula as in |
data |
data frame with data. |
weig |
Vector of weights for each observations. |
bw |
Smoothing parameter, bandwidth. |
kernel |
Kernel used to perform the estimation, see
|
deg |
Local polynomial estimation degree (p). |
xeval |
Vector of evaluation points. By default |
xevalLen |
Length of |
x |
A |
object |
A |
... |
Any other required argument. |
This is an interface to the local polynomial estimation function
that provides basic lm
functionality. summary
and
print
methods shows very basic information about the fit,
fitted
return the estimation of the derivatives if deg
is larger than 0, and plot
provides a plot of data, local
polynomial estimation and the variance estimation.
Variance estimation is carried out by means of the local constant regression estimation of the squared residuals.
confInterval
provides confidence intervals for all points
in x$lpFit$[,x$X]
, say those in xeval
.
A list containing among other components:
mf |
Model frame for |
data |
data frame with data. |
weig |
Vector of weight for each observations. |
xeval |
Vector of evaluation points. |
bw |
Smoothing parameter, bandwidth. |
kernel |
Kernel used, see |
KName |
Kernel name, a string with the name of kernel. |
deg |
Local polynomial estimation degree (p). |
X,Y |
Names in |
residuals |
Residuals of the local polynomial fit. |
lpFit |
Data frame with the local polynomial fit. It contains covariate, response, derivatives estimation, X density estimation, and variance estimation. |
Jorge Luis Ojeda Cabrera.
Fan, J. and Gijbels, I. Local polynomial modelling and its applications\/. Chapman & Hall, London (1996).
Wand, M.~P. and Jones, M.~C. Kernel smoothing\/. Chapman and Hall Ltd., London (1995).
Crist'obal, J. A. and Alcal\'a, J. T. (2000). Nonparametric regression estimators for length biased data\/. J. Statist. Plann. Inference, 89, pp. 145-168.
Ahmad, Ibrahim A. (1995) On multivariate kernel estimation for samples from weighted distributions\/. Statistics & Probability Letters, 22, num. 2, pp. 121-129
locpoly
from package KernSmooth,
ksmooth
and loess
in stats (but from earlier package modreg
).
N <- 250 xeval <- 0:100/100 ## ex1 d <- data.frame(x = runif(N)) d$y <- d$x^2 - d$x + 1 + rnorm(N, sd = 0.1) r <- locpol(y~x,d) plot(r) ## ex2 d <- data.frame(x = runif(N)) d$y <- d$x^2 - d$x + 1 + (1+d$x)*rnorm(N, sd = 0.1) r <- locpol(y~x,d) plot(r) ## notice: rr <- locpol(y~x,d,xeval=runif(50,-1,1)) ## notice x has null dens. outside (0,1) ## plot(rr) raises an error, no conf. bands outside (0,1). ## length biased data !! d <- data.frame(x = runif(10*N)) d$y <- d$x^2 - d$x + 1 + (rexp(10*N,rate=4)-.25) posy <- d$y[ whichYPos <- which(d$y>0) ]; d <- d[sample(whichYPos, N,prob=posy,replace=FALSE),] rBiased <- locpol(y~x,d) r <- locpol(y~x,d,weig=1/d$y) plot(d) points(r$lpFit[,r$X],r$lpFit[,r$Y],type="l",col="blue") points(rBiased$lpFit[,rBiased$X],rBiased$lpFit[,rBiased$Y],type="l") curve(x^2 - x + 1,add=TRUE,col="red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.