if (FALSE) ## Generate some data.
set.seed(123)
n <- 300
x <- runif(n, -2, 3)
y <- sin(x) + rnorm(n, sd = 0.1)
## Increasing: constr = 1.
## Decreasing: constr = 2.
b <- bamlss(y ~ s2(x,bs="ms",xt=list(constr=1)),
data = d, sampler = FALSE, optimizer = opt_bfit)
## Predict and plot.
p <- predict(b, model = "mu")
plot(y ~ x)
plot2d(p ~ x, add = TRUE, col.lines = 4, lwd = 2)
Run the code above in your browser using DataLab