Last updated: 2025-05-16

Checks: 7 0

Knit directory: BOSS_website/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20250415) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version ebad34e. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.DS_Store
    Ignored:    data/.DS_Store
    Ignored:    data/dimension/
    Ignored:    data/sim3/
    Ignored:    output/.DS_Store

Untracked files:
    Untracked:  marginal_beta_robust.aux
    Untracked:  marginal_beta_robust.log
    Untracked:  marginal_beta_robust.pdf
    Untracked:  marginal_beta_robust.tex

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/sim3.Rmd) and HTML (docs/sim3.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd ebad34e david.li 2025-05-16 wflow_publish("analysis/sim3.Rmd")
html 7576b9d david.li 2025-05-16 Build site.
Rmd b0252b6 david.li 2025-05-16 wflow_publish("analysis/sim3.Rmd")
html 2cfedcf david.li 2025-05-13 Build site.
Rmd e7fb0fb david.li 2025-05-13 wflow_publish("analysis/sim3.Rmd")
html 3cce049 david.li 2025-05-09 Build site.
Rmd c17bcc1 david.li 2025-05-09 wflow_publish("analysis/sim3.Rmd")
html 6120746 david.li 2025-05-09 Build site.
Rmd 85dca70 david.li 2025-05-09 wflow_publish("analysis/sim3.Rmd")
html e2f7ebc david.li 2025-05-09 Build site.
Rmd 8f83f92 david.li 2025-05-09 wflow_publish("analysis/sim3.Rmd")
html acac9ba david.li 2025-05-09 Build site.
Rmd c72ffd4 david.li 2025-05-09 wflow_publish("analysis/sim3.Rmd")
html 1881d2e david.li 2025-05-08 Build site.
Rmd 3270116 david.li 2025-05-08 wflow_publish("analysis/sim3.Rmd")
html 43c115a david.li 2025-05-07 Build site.
Rmd a114090 david.li 2025-05-07 wflow_publish("analysis/sim3.Rmd")
Rmd 304b28d Ziang Zhang 2025-05-05 update
html a07691d david.li 2025-04-20 Build site.
html 3478135 david.li 2025-04-20 Build site.
Rmd 3f8195f david.li 2025-04-20 wflow_publish("analysis/sim3.Rmd")
html 6cea47c david.li 2025-04-20 Build site.
Rmd d9facf4 david.li 2025-04-20 wflow_publish("analysis/sim3.Rmd")
html 657dd74 david.li 2025-04-20 Build site.
Rmd 1026e5b david.li 2025-04-20 wflow_publish("analysis/sim3.Rmd")
html 3528574 david.li 2025-04-20 Build site.
html 13358d2 david.li 2025-04-20 Build site.
Rmd 78186b1 david.li 2025-04-20 Simulation 3
html 78186b1 david.li 2025-04-20 Simulation 3
html cc32863 david.li 2025-04-19 Build site.
Rmd 2011696 david.li 2025-04-19 wflow_publish("analysis/sim3.Rmd")

Data

library(tidyverse)
library(tikzDevice)
library(rstan)
library(INLA)
library(inlabru)
library(modeest)

function_path <- "./code"
output_path <- "./output/sim3"
data_path <- "./data/sim3"
source(paste0(function_path, "/00_BOSS.R"))

Consider the following non-linear regression model:

\[\begin{align*} y_i \mid \log(\rho_i) &\overset{ind}{\sim}\mathcal{N}(\log\rho(r_i), \sigma^2), \\ \log\rho(r_i) &= \log\rho_0 - \gamma\log\left\{1 + (r_i/R)^\beta\right\}. \end{align*}\]

We simulate \(n = 200\) data points based on the above model with \(\rho_0 = 10\), \(R = 2\), \(\beta = 2\), \(\gamma = -2.5\), and \(\sigma = 0.5\). The inferential goal is the nuisance parameters \(R\) and \(\beta\).

r <- seq(0, 20, length.out = 50)
beta <- 10
a <- 2
b <- 2
c <- -2.5

set.seed(1234)
Ir <- beta*(1 + (r/a)^b)^c
lr <- log(Ir) + rnorm(length(r), 0, 0.5)

data <- data.frame(r, lr)

ggplot(data, aes(r, lr)) + geom_point() + ylab('y')

Version Author Date
2cfedcf david.li 2025-05-13
cc32863 david.li 2025-04-19

inlabru

We first run inlabru to to fit the model. We set the following priors for the parameters:

\[\begin{align*} \rho_0 \sim \mathcal{N}(0, 1000), \ & R \sim \mathrm{Unif}(0.1, 5), \\ \beta \sim \mathrm{Unif}(0.1, 4), \ \gamma \sim \mathcal{N}(0, & 1000), \ \sigma^2 \sim \mathrm{Inv-Gamma}(1, 10^{-5}). \end{align*}\]

a_fun <- function(u){
  qunif(pnorm(u), 0.1, 5)
}

b_fun <- function(u){
  qunif(pnorm(u), 0.1, 4)
}

cmp <- ~ a(1, model="linear", mean.linear=0, prec.linear=1) +
  b(1, model="linear", mean.linear=0, prec.linear=1) + 
  c(1) + Intercept(1)

form <- lr ~ Intercept + c*log(1 + (r/a_fun(a))^b_fun(b))

fit <- bru(cmp, formula = form, data = data, family = 'gaussian')

BOSS

Now let’s run BOSS.

BOSS-modal

We first specify the (unnormalized) log-posterior for \((R,\beta)\). Note that for this specific problem, the unnormalized log-posterior has a closed-form expression:

# specify the objective function for BOSS: unnormalized log posterior of (R, beta)
eval_func <- function(par, x = r, y = lr){
  a <- par[1]
  b <- par[2]
  n <- length(r)
  
  X <- matrix(cbind(rep(1, n), log(1 + (r/a)^b)), ncol = 2)
  Vb <- solve(t(X) %*% X + diag(1/1000, 2))
  P <- diag(n) - X %*% Vb %*% t(X)
  
  mlik <- log(det(Vb))/2 - log(1000) + lgamma((n+1)/2) - (n+1)/2*log(1e-5 + t(y) %*% P %*% y/2) - 
    n/2*log(pi) -5*log(10)
  
  return(mlik)
}

BOSS-modal

Next, we run the BOSS algorithm where the stopping criteria is based on the convergence of the posterior mode. Specifically, we check the modal convergence every BO iteration, and consider the convergence statistics of the average \(5\) nearest neighbor distance around the current mode.

set.seed(1234)
res_opt_modal <- BOSS(eval_func, criterion = 'modal', update_step = 5, max_iter = 100, D = 2,
                      lower = rep(0.1, 2), upper = c(5, 4),
                      noise_var = 1e-6,
                      modal_iter_check = 1,  modal_check_warmup = 20, modal_k.nn = 5,
                      modal_eps = 0.01,
                      initial_design = 5, delta = 0.01^2,
                      optim.n = 5, optim.max.iter = 100)

save(res_opt_modal, file = paste0(output_path, "/BOSS_modal_sim3.rda"))

The above BOSS algorithm with modal convergence criterion converged in \(91\) iterations.

Let’s check the convergence diagnostic plot:

load(paste0(output_path, "/BOSS_modal_sim3.rda"))

plot(res_opt_modal$modal_result$modal_max_diff ~ res_opt_modal$modal_result$i, type = 'o', xlab = 'Iteration', ylab = 'Modal Stats')

Version Author Date
2cfedcf david.li 2025-05-13
43c115a david.li 2025-05-07

MCMC

Lastly, we implement the MCMC-based method using stan to obtain the oracle.

set.seed(1234)
MCMC_fit <- stan(
  file = "code/nlreg.stan",  # Stan program
  data = list(x = r, y = lr, N = length(r)),    # named list of data
  chains = 4,             # number of Markov chains
  warmup = 3000,          # number of warmup iterations per chain
  iter = 30000,            # total number of iterations per chain
  cores = 4,              # number of cores (could use one per chain)
  algorithm = 'NUTS')

# thin the samples fo plotting
MCMC_samp <- as.data.frame(MCMC_fit)
#MCMC_samp_thin <- MCMC_samp[seq(1, 76000, by = 8),]
save(MCMC_samp, file = paste0(output_path, "/MCMC_sim3.rda"))

Results Comparison

Marginal Posterior Distributions

We first compare the marginal posterior distributions of \(R\) and \(\beta\) from inlabru, BOSS, and MCMC.

# inlabru marginal samples
set.seed(1234)
inla.samples.a <- a_fun(inla.rmarginal(108000, fit$marginals.fixed$a))
inla.samples.b <- b_fun(inla.rmarginal(108000, fit$marginals.fixed$b))
# BOSS-modal marginal samples
data_to_smooth <- list()
unique_data <- unique(data.frame(x = res_opt_modal$result$x, y = res_opt_modal$result$y))
data_to_smooth$x <- as.matrix(dplyr::select(unique_data, -y))
data_to_smooth$y <- (unique_data$y - mean(unique_data$y))

square_exp_cov <- square_exp_cov_generator_nd(length_scale = res_opt_modal$length_scale, signal_var = res_opt_modal$signal_var)

surrogate <- function(xvalue, data_to_smooth, cov){
  predict_gp(data_to_smooth, x_pred = xvalue, choice_cov = cov, noise_var = 1e-6)$mean
}

ff <- list()
ff$fn <- function(x) as.numeric(surrogate(x, data_to_smooth = data_to_smooth, cov = square_exp_cov))

x.1 <- (seq(from = 0.1, to = 5, length.out = 500) - 0.1)/4.9
x.2 <- (seq(from = 0.1, to = 4, length.out = 500) - 0.1)/3.9
x_vals <- expand.grid(x.1, x.2)
names(x_vals) <- c('x.1','x.2')
x_original <- t(t(x_vals)*(c(5, 4) - c(0.1, 0.1)) + c(0.1, 0.1)) 

fn_vals <- apply(x_vals, 1, function(x) ff$fn(x = matrix(x, ncol = 2))) + mean(unique_data$y)
fn_true <- apply(x_original, 1, function(x) eval_func(x))
# normalize
lognormal_const <- log(sum(exp(fn_vals))*0.0098*0.0078)
lognormal_const_true <- log(sum(exp(fn_true))*0.0098*0.0078)

post_x_modal <- data.frame(x_original, pos = exp(fn_vals - lognormal_const))
post_x_true <- data.frame(x_original, pos = exp(fn_true - lognormal_const_true))

save(post_x_modal, file = paste0(output_path, "/BOSS_post.rda"))
save(post_x_true, file = paste0(output_path, "/true_post.rda"))
load(paste0(output_path, "/BOSS_post.rda"))
load(paste0(output_path, "/true_post.rda"))

dx <- unique(post_x_modal$x.1)[2] - unique(post_x_modal$x.1)[1]
dy <- unique(post_x_modal$x.2)[2] - unique(post_x_modal$x.2)[1]
set.seed(123456)
sample_idx <- rmultinom(1:250000, size = 108000, prob = post_x_modal$pos)
sample_x_modal <- data.frame(post_x_modal, n = sample_idx)
sample_idx_true <- rmultinom(1:250000, size = 108000, prob = post_x_true$pos)
sample_x_true <- data.frame(post_x_true, n = sample_idx_true)

samples_BOSS_modal <- data.frame(do.call(rbind, apply(sample_x_modal, 1, function(x) cbind(runif(x[4], x[1], x[1]+dx), runif(x[4], x[2], x[2] + dy)))))
samples_true <- data.frame(do.call(rbind, apply(sample_x_true, 1, function(x) cbind(runif(x[4], x[1], x[1]+dx), runif(x[4], x[2], x[2] + dy)))))

# MCMC marginal samples
load(paste0(output_path, "/MCMC_sim3.rda"))

# Combine all samples together

R_marginal <- data.frame(R = c(inla.samples.a, samples_BOSS_modal[,1], MCMC_samp$a,
                               samples_true[,1]), 
                         method = rep(c('inlabru', 'BOSS',  'MCMC', 'Grid (Oracle)'),  
                                      c(length(inla.samples.a), 
                                        length(samples_BOSS_modal[,1]), 
                                        length(MCMC_samp$a), length(samples_true[,1]))))

beta_marginal <- data.frame(beta = c(inla.samples.b, samples_BOSS_modal[,2], MCMC_samp$b,
                                     samples_true[,2]), 
                            method = rep(c('inlabru', 'BOSS', 'MCMC', 'Grid (Oracle)'),  
                                         c(length(inla.samples.b),
                                           length(samples_BOSS_modal[,2]),  
                                           length(MCMC_samp$b), length(samples_true[,2]))))

Plot the marginal posterior densities

#tikz(file = "R_marginal.tex", standAlone=T, width = 4, height = 3)
ggplot(R_marginal, aes(R)) + geom_density(aes(color = method), show_guide = F) +
  stat_density(aes(x = R, colour = method),
                  geom="line",position="identity") + theme_minimal() + xlab('$R$')
Warning: The `show_guide` argument of `layer()` is deprecated as of ggplot2 2.0.0.
ℹ Please use the `show.legend` argument instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
generated.

Version Author Date
7576b9d david.li 2025-05-16
2cfedcf david.li 2025-05-13
3cce049 david.li 2025-05-09
43c115a david.li 2025-05-07
3478135 david.li 2025-04-20
78186b1 david.li 2025-04-20
cc32863 david.li 2025-04-19
#dev.off()
#system('pdflatex R_marginal.tex')
#tikz(file = "beta_marginal.tex", standAlone=T, width = 4, height = 3)
ggplot(beta_marginal, aes(beta)) + geom_density(aes(color = method), show_guide = F) +
  stat_density(aes(x = beta, colour = method),
                  geom="line",position="identity") + theme_minimal() + xlab('$\\beta$')

Version Author Date
7576b9d david.li 2025-05-16
2cfedcf david.li 2025-05-13
43c115a david.li 2025-05-07
3478135 david.li 2025-04-20
#dev.off()
#system('pdflatex beta_marginal.tex')

Joint Posterior Distribution

We now compare the results of the posterior distributions from inlabru, modal-based BOSS, and AGHQ-based BOSS, and MCMC.

inlabru joint posterior distribution:

# get joint posterior of (R, beta) from inlabru
joint_samp <- inla.posterior.sample(10000, fit, selection = list(a = 1, b = 1), seed = 12345)
joint_samp <- do.call('rbind', lapply(joint_samp, function(x) matrix(x$latent, ncol = 2)))

inla.joint.samps <- data.frame(a = a_fun(joint_samp[,1]), b = b_fun(joint_samp[,2]))

# plot joint posterior of (R, beta) from inlabru
#tikz(file = "joint_post_R_beta_inlabru.tex", standAlone=T, width = 4, height = 3)
ggplot(inla.joint.samps, aes(a, b)) + stat_density_2d(
  geom = "raster",
  aes(fill = after_stat(density)), n = 300,
  contour = FALSE) +
  geom_point(data = data.frame(a = a_fun(fit$summary.fixed$mode[1]), b = b_fun(fit$summary.fixed$mode[2])), color = 'red', shape = 1, size =0.5) + 
  geom_point(data = data.frame(a = 2, b = 2), color = 'orange', size =0.5) +
  coord_fixed() + scale_fill_viridis_c(name = 'Density') + theme_minimal() + xlab('$R$') + ylab('$\\beta$') + xlim(c(0.1, 5)) + ylim(c(0.1, 4))

Version Author Date
2cfedcf david.li 2025-05-13
43c115a david.li 2025-05-07
3478135 david.li 2025-04-20
#dev.off()
#system('pdflatex joint_post_R_beta_inlabru.tex')

BOSS joint posterior distribution:

# plot joint posterior of (R, beta) from BOSS
#tikz(file = "joint_post_R_beta.tex", standAlone=T, width = 4, height = 3)
ggplot(post_x_modal, aes(x.1,x.2)) + geom_raster(aes(fill = (pos))) + 
  geom_point(data = data.frame(x.1 = post_x_modal$x.1[which.max(post_x_modal$pos)], x.2 = post_x_modal$x.2[which.max(post_x_modal$pos)]), color = 'red', shape = 1, size =0.5) +
  geom_point(data = data.frame(x.1 = 2, x.2 = 2), color = 'orange', size =0.5) + coord_fixed() + scale_fill_viridis_c(name = 'Density') + theme_minimal() + xlab('$R$') + ylab('$\\beta$')

Version Author Date
2cfedcf david.li 2025-05-13
43c115a david.li 2025-05-07
3478135 david.li 2025-04-20
#dev.off()
#system('pdflatex joint_post_R_beta.tex')

MCMC joint posterior distribution:

#tikz(file = "joint_post_R_beta_MCMC.tex", standAlone=T, width = 4, height = 3)
ggplot(MCMC_samp, aes(a, b)) + stat_density_2d(
  geom = "raster",
  aes(fill = after_stat(density)), n = 300,
  contour = FALSE) + 
  geom_point(data = data.frame(a = post_x_modal$x.1[which.max(post_x_modal$pos)], b = post_x_modal$x.2[which.max(post_x_modal$pos)]), color = 'red', shape = 1, size =0.5) +
  geom_point(data = data.frame(a = 2, b = 2), color = 'orange', size =0.5) + coord_fixed() + scale_fill_viridis_c(name = 'Density') + theme_minimal() + xlab('$R$') + ylab('$\\beta$') + xlim(c(0.1, 5)) + ylim(c(0.1, 4))

Version Author Date
2cfedcf david.li 2025-05-13
#dev.off()
#system('pdflatex joint_post_R_beta_MCMC.tex')

True joint posterior distribution (grid):

# plot joint posterior of (R, beta) from BOSS
#tikz(file = "joint_post_R_beta_oracle.tex", standAlone=T, width = 4, height = 3)
ggplot(post_x_true, aes(x.1,x.2)) + geom_raster(aes(fill = (pos))) + 
  geom_point(data = data.frame(x.1 = post_x_true$x.1[which.max(post_x_true$pos)], x.2 = post_x_true$x.2[which.max(post_x_true$pos)]), color = 'red', shape = 1, size =0.5) +
  geom_point(data = data.frame(x.1 = 2, x.2 = 2), color = 'orange', size =0.5) + coord_fixed() + scale_fill_viridis_c(name = 'Density') + theme_minimal() + xlab('$R$') + ylab('$\\beta$')

Version Author Date
2cfedcf david.li 2025-05-13
43c115a david.li 2025-05-07
#dev.off()
#system('pdflatex joint_post_R_beta_oracle.tex')

From the above results, it is clear that BOSS is much better at depicting the joint posterior distribution than inlabru. The joint distribution from inlabru is simply the product of the marginal distribution, which completely ignores the more complex structures in the joint posterior. Interestingly though, BOSS is also much better than HMC. The posterior samples from HMC is significantly oversampling from the tail regions. This is likely due to highly warped geometry of the posterior and the un-optimized step number and step size used in the NUTS sampler.

Does Starting Design Points Matter?

We here check if BOSS is robust towards the starting design points. We run BOSS for \(20\) times with different initial design points and run until the modal statistics have reached below \(\epsilon =0.01\).

res_list <- vector('list', 20)

for (i in 1:20) {
  set.seed(i)
  res_list[[i]] <- BOSS(eval_func, criterion = 'modal', update_step = 5, max_iter = 100, D = 2,
                        lower = rep(0.1, 2), upper = c(5, 4),
                        noise_var = 1e-6,
                        modal_iter_check = 1,  modal_check_warmup = 20, modal_k.nn = 5,
                        modal_eps = 0.01,
                        initial_design = 5, delta = 0.01^2,
                        optim.n = 5, optim.max.iter = 100)
}

save(res_list, file = paste0(output_path, "/BOSS_robust_sim3.rda"))
load(paste0(output_path, "/BOSS_robust_sim3.rda"))

sample_list <- vector('list', 20)

for(i in 1:20){
  # BOSS-modal marginal samples
  data_to_smooth <- list()
  unique_data <- unique(data.frame(x = res_list[[i]]$result$x, y = res_list[[i]]$result$y))
  data_to_smooth$x <- as.matrix(dplyr::select(unique_data, -y))
  data_to_smooth$y <- (unique_data$y - mean(unique_data$y))
  
  square_exp_cov <- square_exp_cov_generator_nd(length_scale = res_list[[i]]$length_scale, signal_var = res_list[[i]]$signal_var)
  
  surrogate <- function(xvalue, data_to_smooth, cov){
    predict_gp(data_to_smooth, x_pred = xvalue, choice_cov = cov, noise_var = 1e-6)$mean
  }
  
  ff <- list()
  ff$fn <- function(x) as.numeric(surrogate(x, data_to_smooth = data_to_smooth, cov = square_exp_cov))
  
  x.1 <- (seq(from = 0.1, to = 5, length.out = 300) - 0.1)/4.9
  x.2 <- (seq(from = 0.1, to = 4, length.out = 300) - 0.1)/3.9
  x_vals <- expand.grid(x.1, x.2)
  names(x_vals) <- c('x.1','x.2')
  x_original <- t(t(x_vals)*(c(5, 4) - c(0.1, 0.1)) + c(0.1, 0.1)) 
  
  fn_vals <- apply(x_vals, 1, function(x) ff$fn(x = matrix(x, ncol = 2))) + mean(unique_data$y)
  # normalize
  lognormal_const <- log(sum(exp(fn_vals))*0.0098*0.0078*25/9)
  post_x_modal <- data.frame(x_original, pos = exp(fn_vals - lognormal_const))
  
  dx <- unique(post_x_modal$x.1)[2] - unique(post_x_modal$x.1)[1]
  dy <- unique(post_x_modal$x.2)[2] - unique(post_x_modal$x.2)[1]
  set.seed(123456)
  sample_idx <- rmultinom(1:90000, size = 49500, prob = post_x_modal$pos)
  sample_x_modal <- data.frame(post_x_modal, n = sample_idx)
  
  sample_list[[i]] <- data.frame(do.call(rbind, apply(sample_x_modal, 1, function(x) cbind(runif(x[4], x[1], x[1]+dx), runif(x[4], x[2], x[2] + dy)))))
  
}

save(sample_list, file = paste0(output_path, "/BOSS_sample_small_n_sim3.rda"))
load(paste0(output_path, "/BOSS_sample_small_n_sim3.rda"))

p_R <- ggplot(samples_true, aes(x = X1)) + theme_minimal() + xlab('$R$')

for (i in 1:20) {
  p_R <- p_R + geom_density(data = sample_list[[i]], aes(x = X1), color = 'red', alpha = 0.1)
}

p_R <- p_R + geom_density(color = 'black', size = 1.5) 
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
generated.
#tikz(file = "marginal_R_robust.tex", standAlone=T, width = 4, height = 3)
p_R

Version Author Date
2cfedcf david.li 2025-05-13
#dev.off()
#system('pdflatex marginal_R_robust.tex')

p_b <- ggplot(samples_true, aes(x = X2)) + theme_minimal() + xlab('$\\beta$')

for (i in 1:20) {
  p_b <- p_b + geom_density(data = sample_list[[i]], aes(x = X2), color = 'red', alpha = 0.1)
}

p_b <- p_b + geom_density(color = 'black', size = 1.5) 

#tikz(file = "marginal_beta_robust.tex", standAlone=T, width = 4, height = 3)
p_b

Version Author Date
2cfedcf david.li 2025-05-13
#dev.off()
#system('pdflatex marginal_beta_robust.tex')

In the above, black density comes from the grid-based oracle posterior while red ones come from BOSS. We can see that BOSS is highly robust to the initial design points selection.


sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS 15.0

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Toronto
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] modeest_2.4.0       inlabru_2.11.1      fmesher_0.1.7      
 [4] INLA_24.06.27       sp_2.1-4            Matrix_1.7-0       
 [7] rstan_2.32.6        StanHeaders_2.32.10 tikzDevice_0.12.6  
[10] lubridate_1.9.3     forcats_1.0.0       stringr_1.5.1      
[13] dplyr_1.1.4         purrr_1.0.2         readr_2.1.5        
[16] tidyr_1.3.1         tibble_3.2.1        ggplot2_3.5.1      
[19] tidyverse_2.0.0     workflowr_1.7.1    

loaded via a namespace (and not attached):
 [1] mnormt_2.1.1        DBI_1.2.3           gridExtra_2.3      
 [4] inline_0.3.19       rlang_1.1.4         magrittr_2.0.3     
 [7] clue_0.3-65         git2r_0.33.0        matrixStats_1.4.1  
[10] e1071_1.7-16        compiler_4.4.1      getPass_0.2-4      
[13] loo_2.8.0           callr_3.7.6         vctrs_0.6.5        
[16] rmutil_1.1.10       crayon_1.5.3        pkgconfig_2.0.3    
[19] fastmap_1.2.0       labeling_0.4.3      utf8_1.2.4         
[22] promises_1.3.0      rmarkdown_2.28      tzdb_0.4.0         
[25] ps_1.8.0            MatrixModels_0.5-3  xfun_0.47          
[28] cachem_1.1.0        jsonlite_1.8.9      highr_0.11         
[31] later_1.3.2         parallel_4.4.1      cluster_2.1.6      
[34] R6_2.5.1            bslib_0.8.0         stringi_1.8.4      
[37] rpart_4.1.23        numDeriv_2016.8-1.1 jquerylib_0.1.4    
[40] Rcpp_1.0.13         knitr_1.48          filehash_2.4-6     
[43] httpuv_1.6.15       splines_4.4.1       timechange_0.3.0   
[46] tidyselect_1.2.1    rstudioapi_0.16.0   yaml_2.3.10        
[49] timeDate_4041.110   codetools_0.2-20    processx_3.8.4     
[52] pkgbuild_1.4.4      lattice_0.22-6      plyr_1.8.9         
[55] withr_3.0.1         evaluate_1.0.0      stable_1.1.6       
[58] sf_1.0-19           units_0.8-5         proxy_0.4-27       
[61] RcppParallel_5.1.10 pillar_1.9.0        whisker_0.4.1      
[64] KernSmooth_2.23-24  stats4_4.4.1        sn_2.1.1           
[67] generics_0.1.3      rprojroot_2.0.4     hms_1.1.3          
[70] munsell_0.5.1       scales_1.3.0        timeSeries_4041.111
[73] class_7.3-22        glue_1.7.0          statip_0.2.3       
[76] tools_4.4.1         spatial_7.3-17      fBasics_4041.97    
[79] fs_1.6.4            grid_4.4.1          QuickJSR_1.6.0     
[82] colorspace_2.1-1    cli_3.6.3           fansi_1.0.6        
[85] viridisLite_0.4.2   gtable_0.3.5        stabledist_0.7-2   
[88] sass_0.4.9          digest_0.6.37       classInt_0.4-10    
[91] farver_2.1.2        htmltools_0.5.8.1   lifecycle_1.0.4    
[94] httr_1.4.7          MASS_7.3-61