if (FALSE) {
#####################
# Increasing-convex #
#####################
# Simulate data
set.seed(1)
n <- 200
x <- runif(n)
e <- c(rnorm(n/2, sd = 0.5), rnorm(n/2, sd = 3))
y <- exp(6*x - 3) + e
# Number of cosine basis functions
nbasis <- 50
# Fit the model with default priors and mcmc parameters
fout <- bsardpm(y ~ fs(x), nbasis = nbasis, shape = 'IncreasingConvex')
# Prediction
xnew <- runif(n)
predict(fout, newnp = xnew)
}
Run the code above in your browser using DataLab