lls<-function(x, y, h, grid, method=1,iker = 1)
{ # SIMPLE BUT NAIVE IMPLEMENTATION of
# local constant or local linear with kernel symmetric beta kernel
# (1-u^2)^iker and bandwidth h, evaluated at "grid".
#method = 0, local linear fit;
# = 1, local constant fit
#iker is an integer.
#result: grid, est
ngrid<-length(grid)
res <- rep(0,ngrid)
for (j in 1:ngrid)
{ w <- locw(x,grid[j],h) #Epanechnikov kernel
x0 <- x[ w > 0] #local data
y0 <- y[ w > 0]
w <- w[w > 0]
w <- w^iker
coef <- lsfit(x0-grid[j],y0,w)$coef
if(method==1)
res[j] <- lsfit(x0-grid[j],y0,w)$coef[1]
else
res[j] <- lsfit(x0-grid[j],y0,w,intercept=FALSE)$coef[1]
}
list(grid=grid,est=res)
}