if (FALSE) {
##########################################
# Increasing Convex to Concave (S-shape) #
##########################################
# simulate data
f <- function(x) 5*exp(-10*(x - 1)^4) + 5*x^2
set.seed(1)
n <- 100
x <- runif(n)
y <- f(x) + rnorm(n, sd = 1)
# Number of cosine basis functions
nbasis <- 50
# Fit the model with default priors and mcmc parameters
fout <- bsar(y ~ fs(x), nbasis = nbasis, shape = 'IncreasingConvex',
spm.adequacy = TRUE)
# Prediction
xnew <- runif(n)
predict(fout, newnp = xnew)
}
Run the code above in your browser using DataLab