# NOT RUN {
n <- 2000
x <- c(rnorm(n/2,2,1), rnorm(n/2, -2,1))
sig <- .8
u <- sig*rnorm(n)
w <- x+u
e <- rnorm(n, sd=0.2)
y <- x^2-2*x+e
bw1 <- bw.dboot1(w, sig)
u0 <- sig*rnorm(n/2) # typically the size of u0 is smaller than x.
m2 <- npreg(w, y, u0, from=0.9*min(x), to=0.9*max(x))
# plot the results
plot(m2, col="red", lwd=3, lty=2, xlab="x", ylab="m(x)", main="",
zero.line=FALSE)
lines(ksmooth(x,y, kernel = "normal", 2, range.x=c(0.9*min(x),0.9*max(x))),
lwd=3, lty=1)
lines(ksmooth(w,y, kernel = "normal", 2, range.x=c(0.9*min(x),0.9*max(x))),
col="blue", lwd=3, lty=3)
# }
Run the code above in your browser using DataLab