R Under development (unstable) (2026-05-11 r90046 ucrt) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(BayesPPR) > f <- function(xx) + { + ########################################################################## + # + # WELCH ET AL. (1992) FUNCTION + # + # Authors: Sonja Surjanovic, Simon Fraser University + # Derek Bingham, Simon Fraser University + # Questions/Comments: Please email Derek Bingham at dbingham@stat.sfu.ca. + # + # Copyright 2013. Derek Bingham, Simon Fraser University. + # + # THERE IS NO WARRANTY, EXPRESS OR IMPLIED. WE DO NOT ASSUME ANY LIABILITY + # FOR THE USE OF THIS SOFTWARE. If software is modified to produce + # derivative works, such modified software should be clearly marked. + # Additionally, this program is free software; you can redistribute it + # and/or modify it under the terms of the GNU General Public License as + # published by the Free Software Foundation; version 2.0 of the License. + # Accordingly, this program is distributed in the hope that it will be + # useful, but WITHOUT ANY WARRANTY; without even the implied warranty + # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + # General Public License for more details. + # + # For function details and reference information, see: + # http://www.sfu.ca/~ssurjano/ + # + ########################################################################## + # + # INPUT: + # + # xx = c(x1, x2, ..., 20) + # + ########################################################################## + + x1 <- xx[1] - 0.5 + x2 <- xx[2] - 0.5 + x3 <- xx[3] - 0.5 + x4 <- xx[4] - 0.5 + x5 <- xx[5] - 0.5 + x6 <- xx[6] - 0.5 + x7 <- xx[7] - 0.5 + x8 <- xx[8] - 0.5 + x9 <- xx[9] - 0.5 + x10 <- xx[10] - 0.5 + x11 <- xx[11] - 0.5 + x12 <- xx[12] - 0.5 + x13 <- xx[13] - 0.5 + x14 <- xx[14] - 0.5 + x15 <- xx[15] - 0.5 + x16 <- xx[16] - 0.5 + x17 <- xx[17] - 0.5 + x18 <- xx[18] - 0.5 + x19 <- xx[19] - 0.5 + x20 <- xx[20] - 0.5 + + term1 <- 5*x12 / (1+x1) + term2 <- 5 * (x4-x20)^2 + term3 <- x5 + 40*x19^3 - 5*x19 + term4 <- 0.05*x2 + 0.08*x3 - 0.03*x6 + term5 <- 0.03*x7 - 0.09*x9 - 0.01*x10 + term6 <- -0.07*x11 + 0.25*x13^2 - 0.04*x14 + term7 <- 0.06*x15 - 0.01*x17 - 0.03*x18 + + y <- term1 + term2 + term3 + term4 + term5 + term6 + term7 + return(y) + } > > > set.seed(71023) > n <- 5000 > p <- 20 > X <- matrix(runif(n*p), n) > y <- apply(X, 1, f) + rnorm(n, sd = 0.2) > > fit <- bppr(X, y) MCMC iteration 1/10000 (burn) -- May 12 23:50:49 -- n ridge: 0 MCMC iteration 1001/10000 (burn) -- 2.47 secs -- n ridge: 16 MCMC iteration 2001/10000 (burn) -- 5.27 secs -- n ridge: 14 MCMC iteration 3001/10000 (burn) -- 8.09 secs -- n ridge: 14 MCMC iteration 4001/10000 (burn) -- 10.92 secs -- n ridge: 14 MCMC iteration 5001/10000 (burn) -- 13.7 secs -- n ridge: 15 MCMC iteration 6001/10000 (burn) -- 16.45 secs -- n ridge: 14 MCMC iteration 7001/10000 (burn) -- 19.16 secs -- n ridge: 14 MCMC iteration 8001/10000 (burn) -- 22.02 secs -- n ridge: 15 MCMC iteration 9001/10000 (post-burn) -- 24.79 secs -- n ridge: 14 MCMC iteration 10000/10000 (post-burn) -- 27.5 secs -- n ridge: 14 > plot(fit$sd_resid, type = 'l') > > X_test <- matrix(runif(n*p), n) > preds <- predict(fit, X_test) > pred_mn <- apply(preds, 2, mean) > plot(apply(X_test, 1, f), pred_mn) > abline(0, 1, col = 2) > sqrt(mean((apply(X_test, 1, f) - pred_mn)^2)) [1] 0.05404021 > > > > proc.time() user system elapsed 22.12 7.78 29.90