x = flat$x
y = flat$y

plot(x, y, pch = 20)

# lokalno konstantna
h_CV0 = npregbw(xdat = x, ydat = y, regtype = "lc")
m0_cv = locpoly(x, y, degree = 0, bandwidth = h_CV0$bandwidth$x)
lines(m0_cv$x, m0_cv$y, col = 2, lwd = 1.5)

h_CV1 = npregbw(xdat = x, ydat = y, regtype = "ll")
m1_cv = locpoly(x, y, degree = 1, bandwidth = h_CV1$bandwidth$x)
lines(m1_cv$x, m1_cv$y, col = 3, lwd = 1.5)
