## Not run: ------------------------------------
# # n=250 data points are generated from r3 by adding the Gaussian noise with sigma=1/500.
# # The fixed evenly spaced design is used.
# u=seq(0,1,len=1000)
# n=250
# xdat=(1:n-0.5)/n
# ydat=reg3(xdat)+rnorm(n,sd=1/500)
# h_oscv=round(h_OSCV_reg(xdat,ydat,1),digits=4) # L_G-based OSCV based on nonsmooth constant
# l=loclin(u,xdat,ydat,h_oscv)
# dev.new()
# plot(xdat,ydat,pch=20,cex=1.5,cex.axis=1.5,cex.lab=1.5,xlab="x",ylab="y",
# ylim=c(min(ydat),1.2*max(ydat)))
# lines(u,l,'l',lwd=3,col="blue")
# lines(u,reg3(u),lwd=3,lty="dashed")
# title(main="Data, true regression function and LLE",cex.main=1.7)
# legend(-0.05,0.003,legend=paste("h_OSCV=",h_oscv),cex=2,bty="n")
# legend(0.65,0.025, legend="n=250",cex=2,bty="n")
# legend(0,1.28*max(ydat),legend=c("LLE based on h_OSCV","true regression function"),lwd=c(3,3),
# lty=c("solid","dashed"),col=c("blue","black"),bty="n",cex=1.5)
## ---------------------------------------------
Run the code above in your browser using DataLab