# NOT RUN {
# }
# NOT RUN {
## Monotone increasing and concave P-splines example
## simulating data...
set.seed(3)
n <- 100
x <- sort(runif(n)*99+1)
f1 <- log(x)
f <- (f1-min(f1))/(max(f1)-min(f1))
y <- f+rnorm(n)*0.10
dat <- data.frame(x=x,y=y)
## fit model ...
b <- scam(y~s(x,k=15,bs="micv",m=2), data=dat)
# UNCONSTRAINED FIT *****************
b1 <- scam(y~s(x,k=15,bs="ps",m=2),data=dat)
## plot results ...
plot(x,y,xlab="x",ylab="y")
lines(x,f) ## the true function
lines(x,b$fitted.values,col=2) ## mixed constrained fit
lines(x,b1$fitted.values,col=3) ## unconstrained fit
# }
Run the code above in your browser using DataLab