Learn R Programming

sharpData (version 1.2)

NWmono: Monotonized Nadaraya-Watson Regression

Description

Nadaraya-Watson or locally constant regression is applied to bivariate data. The response is `sharpened' or perturbed in a way to render a monotonically increasing curve estimate.

Usage

NWmono(x, y, h, xgrid, numgrid = 401, kernel="biweight", call.plot = 
TRUE, ...)

Arguments

x

a vector of explanatory variable observations

y

binary vector of responses

h

bandwidth

xgrid

gridpoints on x-axis where estimates are taken

numgrid

number of equally-spaced gridpoints (if xgrid not specified)

kernel

character constant

call.plot

if TRUE (default), the data, sharpened data and estimated curve are plotted.

...

other arguments for plot

Value

x

original explanatory variable

y

original responses

ysharp

sharpened responses

h

bandwidth

xgrid

gridpoints

ygrid

sharpened curve estimate

Details

Data are perturbed the smallest possible L2 distance subject to the constraint that the Nadaraya-Watson estimate is monotonically increasing.

References

Braun, W.J. and Hall, P., Data Sharpening for Nonparametric Estimation Subject to Constraints, Journal of Computational and Graphical Statistics, 2001

Examples

Run this code
# NOT RUN {
gridpts <- seq(1, 10, length=101)
x <- seq(1, 10, length=51)
p <- exp(-1 + .2*x)/(1 + exp(-1 + .2*x))
y <- rbinom(51, 1, p)
NWmono(x, y, h=0.6, xgrid=gridpts)
lines(x,p) # true mean response
# }

Run the code above in your browser using DataLab