plot(sin4,0,1,type="l",ylim=c(-1,1.5),xlim=c(0,1) , xlab = "x") lo1 = loess(y ~ x, degree = 1, span = 0.75) ## we are using data generated in ksmooth attributes(lo1) ord = order(lo1$x) lines(lo1$x[ord],lo1$fitted[ord],col="red") plot(lo1$x[ord],lo1$fitted[ord],type="l",col="red", ylim=c(-1,1.5),xlim=c(0,1), xlab = "x") lines(ksmooth(x,y,"normal",bandwidth=0.4),col="blue") lo2 = loess(y~x, degree=1, span=0.4) lo3 = loess(y~x, degree=2, span=0.4) plot(lo1$x[ord],lo1$fitted[ord],type="l",col="red", ylim=c(-1,1.5),xlim=c(0,1), xlab = "x") lines(lo1$x[ord],lo2$fitted[ord],col="green") lines(lo1$x[ord],lo3$fitted[ord],col="purple")