# NOT RUN {
## Example
x <- seq(0,4,length.out=200)
x.long <- seq(0,4,length.out=200)
y <- x^2+rnorm(200,0,2)
dy <- 2*x
dybdd <- cbind(dy-0.5,dy+0.5)
plot(x,y)
ptm <- proc.time()
fit <- constrained.smoothspline(y=y,
times=x,
pen.degree=2,
constraint="none",
derivative.values=NA,
times.new=x.long,
num.folds=5,
lambda="optim")
print(proc.time()-ptm)
fit2 <- smooth.spline(x,y)
lines(x.long,fit[[3]],col="blue")
lines(fit2, col="green")
lines(x.long, x.long^2, col="black")
# }
Run the code above in your browser using DataLab