# NOT RUN {
require(doParallel) # You can use a different package to set up the parallel backend
# Loading the data for this example
data(cell)
true_cell <- c(0.35, 0.001)
# Opening up the parallel pools using doParallel
cl <- makeCluster(detectCores())
registerDoParallel(cl)
# Performing BSL
resultCellBSL <- bsl(cell$data, n = 5000, M = 10000, start = cell$start, cov_rw = cell$cov,
fn_sim = cell_sim, fn_sum = cell_sum, fn_prior = cell_prior,
sim_options = cell$sim_options, sum_options = cell$sum_options,
parallel = TRUE, parallel_packages = 'BSL',
theta_names = c('Pm', 'Pp'))
summary(resultCellBSL)
plot(resultCellBSL, true_value = true_cell, thin = 20)
# Performing tuning for BSLasso
lambda_all <- list(exp(seq(0.5,2.5,length.out=20)), exp(seq(0,2,length.out=20)),
exp(seq(-1,1,length.out=20)), exp(seq(-1,1,length.out=20)))
sp_cell <- selectPenalty(ssy = cell_sum(cell$data, cell$sum_options),
n = c(500, 1000, 1500, 2000), lambda_all, theta = true_cell,
M = 100, sigma = 1.5, fn_sim = cell_sim,
fn_sum = cell_sum, sim_options = cell$sim_options,
sum_options = cell$sum_options, parallel_sim = TRUE,
parallel_sim_packages = 'BSL', parallel_main = TRUE)
sp_cell
plot(sp_cell)
# Performing BSLasso with a fixed penalty
resultCellBSLasso <- bsl(cell$data, n = 1500, M = 10000, start = cell$start,
cov_rw = cell$cov, fn_sim = cell_sim, fn_sum = cell_sum,
penalty = 1.35, fn_prior = cell_prior,
sim_options = cell$sim_options, sum_options = cell$sum_options,
parallel = TRUE, parallel_packages = 'BSL',
theta_names = c('Pm', 'Pp'))
summary(resultCellBSLasso)
plot(resultCellBSLasso, true_value = true_cell, thin = 20)
# Plotting the results together for comparison
combinePlotsBSL(resultCellBSL, resultCellBSLasso, true_value = true_cell, thin = 20)
# Closing the parallel pools
stopCluster(cl)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab