I have been successfully running stan models while specifying control arguments (e.g. adapt_delta, max_treedepth) without issue until yesterday. The only thing I can think of that could have affected it is that I installed the mixOmics package via Bioconductor using the steps outlined here: GitHub - mixOmicsTeam/mixOmics: Development repository for the Bioconductor package 'mixOmics '
After this installation, whenever I run a model where I specify the βcontrolβ argument, I get an error via an Rstudio popup:
If I run chains in parallel using
options(mc.cores = detectCores())
Then the chains start sampling and I see the following output and error:
starting worker pid=25403 on localhost:11771 at 13:08:20.600
starting worker pid=25417 on localhost:11771 at 13:08:20.798
SAMPLING FOR MODEL 'simple-model' NOW (CHAIN 1).
Error in unserialize(socklist[[n]]) : error reading from connection
SAMPLING FOR MODEL 'simple-model' NOW (CHAIN 2).
These both happen with the stan() function and the sampling() function.
I have a 2017 Macbook Pro running Big Sur (11.4). Here is my session info after loading the βstanβ and βparallelβ libraries:
R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.4
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] rstan_2.21.2 ggplot2_3.3.5 StanHeaders_2.21.0-7
loaded via a namespace (and not attached):
[1] Rcpp_1.0.7 pillar_1.6.1 compiler_4.1.0 prettyunits_1.1.1
[5] tools_4.1.0 pkgbuild_1.2.0 jsonlite_1.7.2 lifecycle_1.0.0
[9] tibble_3.1.2 gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.11
[13] DBI_1.1.1 cli_3.0.0 curl_4.3.2 loo_2.4.1
[17] gridExtra_2.3 withr_2.4.2 dplyr_1.0.7 generics_0.1.0
[21] vctrs_0.3.8 stats4_4.1.0 grid_4.1.0 tidyselect_1.1.1
[25] glue_1.4.2 inline_0.3.19 R6_2.5.0 processx_3.5.2
[29] fansi_0.5.0 purrr_0.3.4 callr_3.7.0 magrittr_2.0.1
[33] codetools_0.2-18 matrixStats_0.59.0 scales_1.1.1 ps_1.6.0
[37] ellipsis_0.3.2 assertthat_0.2.1 colorspace_2.0-2 V8_3.4.2
[41] utf8_1.2.1 RcppParallel_5.1.4 munsell_0.5.0 crayon_1.4.1
I uninstalled R and Rstudio and stan and reinstalled them all (making sure to delete all libraries, especially all of the ones that were installed when I installed mixOmics), and shut down and restarted my computer numerous times. The problem persists.
I can fit models perfectly without specifying and control argumentsβI can specify βchiansβ, βiterβ, βthinβ, etc. and it works, both parallel and serial.
In case it matters, my Makevars file is the following:
CXX14FLAGS += -O3 -mtune=native -arch x86_64 -ftemplate-depth-256
Here is a minimal reproducible example for whatβs going on. My stan code is:
data {
int<lower=0> N;
vector[N] y;
}
parameters {
real mu;
real<lower=0> sigma;
}
model {
y ~ normal(mu, sigma);
}
My R code is:
library(rstan); library(parallel);
mu <- 1
sigma <- 1
N <- 100
y <- rnorm(N, mu, sigma)
dat_list <- list(N = N, y = y)
# this works!
res <- stan(file = "/Users/austin/Desktop/simple-model.stan",
data = dat_list)
# this has an error and aborts R
res <- stan(file = "/Users/austin/Desktop/simple-model.stan",
data = dat_list,
control = list(adapt_delta = 0.95))
# for parallel
options(mc.cores = detectCores())
# this works!
res <- stan(file = "/Users/austin/Desktop/simple-model.stan",
data = dat_list)
# this has an error: "Error in unserialize(socklist[[n]]) : error reading from connection"
res <- stan(file = "/Users/austin/Desktop/simple-model.stan",
data = dat_list,
control = list(adapt_delta = 0.95))
Iβm thoroughly baffled by this, especially due to the full reinstallation of R, Rstudio, and Stan. Any ideas and help would be gladly appreciated.