# generate data
set.seed(1)
n <- 100
x <- seq(0, 1, length.out = n)
fx <- 2 + 3 * x + sin(2 * pi * x)
y <- fx + rnorm(n, sd = 0.5)
# fit smoothing spline
ssfit <- ss(x, y, nknots = 10)
# plot smoothing spline fit
plot(ssfit)
if (FALSE) {
# bootstrap smoothing spline
ssfitboot <- boot(ssfit)
# plot smoothing spline bootstrap
plot(ssfitboot)
}
Run the code above in your browser using DataLab