set.seed(1234567)
gam<-4
g <- function(x) (3*sin(x*(gam*pi))+5*cos(x*(gam*pi))+6*x)*x
n<-100
M<-200
noise <- 1
x<-sort(runif(n,0,1))
y<-g(x)+rnorm(n,sd=noise)
z<- seq(min(x)+1/M, max(x)-1/M, length=M) ############xgrid points
h1<-dpill(x,y)
A<-lprOperator(h=h1,x=x,z=z,p=1)
local_fit<-t(A)
ss_1<-c(sign(numericalDerivative(z,g,k=1)))
DR_sharpen(x=x, y=y, xgrid=z, h=h1, constraint_1=ss_1, norm="linf",maxit =10^3)
Run the code above in your browser using DataLab