Error with loo_moment_match

Hi!

I want to compare multiple models with loo, but because many of the observations have a pareto_k > 0.7 I would like to use the moment match option. However, I have this error

  loo1    <- brms::loo(fit)
  loo1_mm <- brms::loo_moment_match(fit, loo1)

Error in .update_pars(x, upars = upars, ...) : 
  length(new_samples) == nrow(pars) is not TRUE
Error: Moment matching failed. Perhaps you did not set 'save_all_pars' to TRUE when fitting your model?

The code to fit the model is the following:


    bformula <- bf(n_foraging | trials(n_total) ~ Habitat * Period 
                                                  + (Habitat|Id) 
                                                  + (Habitat|Trip_id))

    bprior <- c(
      set_prior("normal(0,0.5)", class = "Intercept"),
      set_prior("normal(0,0.5)", class = "b"),
      set_prior("cauchy(0,2)",   class = "sd"),
      set_prior("lkj(1)",        class = "cor")
    )
    
    fit  <- brm(bformula,
                data    = DT,
                family  = binomial,
                prior   = bprior,                
                sample_prior  = TRUE,
                save_all_pars = TRUE,                
                iter    = 2000,              
                chains  = 4,
                cores   = 4,
                seed    = 69,              
                control = list(adapt_delta = 0.85))

And here the dataset: data.csv (21.7 KB)

I know this error was previously reported and presumably fixed, but even after updating all packages I still have the error.

When fitting the model with brm I have this warning message. Just in case it is related to this error:

Argument 'save_all_pars' is deprecated. Please use argument 'all' in function 'save_pars()' instead

Thanks!


  • Operating System: windows 10
  • brms Version: 2.14.2
  • loo Version: 2.3.1.9000
  • R-4.0.3
2 Likes

Thank you! I will check what is happening tomorrow. I am sorry this error still seems to be occurring for some models :-(

The problem should be fixed now on github. I have struggled with this for too long before finding an emberrasingly simple fix that should prevent any further returns of this error in the future.

4 Likes

Thanks @paul.buerkner, it runs without error.

I still get this error (after 1 day of run time!)

>   add_criterion(m1, criterion = "loo", moment_match = T)
Error : $ operator is invalid for atomic vectors
In addition: Warning message:
In parallel::mclapply(X = I, mc.cores = cores, FUN = function(i) loo_moment_match_i_fun(i)) :
  scheduled core 1 encountered error in user code, all values of the job will be affected
Error: Moment matching failed. Perhaps you did not set 'save_pars = save_pars(all = TRUE)' when fitting your model?

But the model has been fit with save_pars = save_pars(all = TRUE) (run and stored in the same session). This is MacOS 10.13, RStudio 1.4.1106, R 4.0.5, the loo dev version (2.4.1.9000) and brms 2.15.0. Or should I also install the dev version for brms?

I suggest trying out the dev version of brms and testing with a smaller data subset to see if that works (so that you don’t need a day). I am sorry this error is still occurring.

Will do (and thank you for making brms, so obviously no need to be sorry!).

And a suggestion: perhaps note in the documentation of brm() that the backend cmdrstan does not allow use of loo (and perhaps also other functions)?

it is moment_match which doesn’t work yet, but tomorrow it will :-)

1 Like

With the dev version (and backend = β€œrstan”), I was able to fit a simpler model and then apply add_criterion(model, criterion = β€œloo”, moment_match = T, cores = 12). However, when I then fit the more complex model (which converges and all indicators look good; dropbox link to model rds file [411 MB]), I suddenly get the same error again (in the same session):

Error : $ operator is invalid for atomic vectors
In addition: Warning message:
In parallel::mclapply(X = I, mc.cores = cores, FUN = function(i) loo_moment_match_i_fun(i)) :
scheduled core 5 encountered error in user code, all values of the job will be affected
Error: Moment matching failed. Perhaps you did not set 'save_pars = save_pars(all = TRUE)' when fitting your model?
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
setting  value                       
version  R version 4.1.0 (2021-05-18)
os       macOS High Sierra 10.13.6   
system   x86_64, darwin17.0          
ui       RStudio                     
language (EN)                        
collate  en_US.UTF-8                 
ctype    en_US.UTF-8                 
tz       America/Denver              
date     2021-06-12                  

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
! package        * version  date       lib source                             
abind            1.4-5    2016-07-21 [1] CRAN (R 4.1.0)                     
arrayhelpers     1.1-0    2020-02-04 [1] CRAN (R 4.1.0)                     
assertthat     * 0.2.1    2019-03-21 [1] CRAN (R 4.1.0)                     
backports        1.2.1    2020-12-09 [1] CRAN (R 4.1.0)                     
base64enc        0.1-3    2015-07-28 [1] CRAN (R 4.1.0)                     
bayesplot        1.8.0    2021-01-10 [1] CRAN (R 4.1.0)                     
bayestestR       0.10.0   2021-05-31 [1] CRAN (R 4.1.0)                     
boot             1.3-28   2021-05-03 [1] CRAN (R 4.1.0)                     
bridgesampling   1.1-2    2021-04-16 [1] CRAN (R 4.1.0)                     
brms           * 2.15.0   2021-06-12 [1] Github (paul-buerkner/brms@ffe2673)
Brobdingnag      1.2-6    2018-08-13 [1] CRAN (R 4.1.0)                     
broom          * 0.7.6    2021-04-05 [1] CRAN (R 4.1.0)                     
cachem           1.0.5    2021-05-15 [1] CRAN (R 4.1.0)                     
callr            3.7.0    2021-04-20 [1] CRAN (R 4.1.0)                     
cellranger       1.1.0    2016-07-27 [1] CRAN (R 4.1.0)                     
checkmate        2.0.0    2020-02-06 [1] CRAN (R 4.1.0)                     
cli              2.5.0    2021-04-26 [1] CRAN (R 4.1.0)                     
coda             0.19-4   2020-09-30 [1] CRAN (R 4.1.0)                     
codetools        0.2-18   2020-11-04 [1] CRAN (R 4.1.0)                     
colorspace       2.0-1    2021-05-04 [1] CRAN (R 4.1.0)                     
colourpicker     1.1.0    2020-09-14 [1] CRAN (R 4.1.0)                     
cowplot          1.1.1    2020-12-30 [1] CRAN (R 4.1.0)                     
crayon           1.4.1    2021-02-08 [1] CRAN (R 4.1.0)                     
crosstalk        1.1.1    2021-01-12 [1] CRAN (R 4.1.0)                     
curl             4.3.1    2021-04-30 [1] CRAN (R 4.1.0)                     
DBI              1.1.1    2021-01-15 [1] CRAN (R 4.1.0)                     
dbplyr           2.1.1    2021-04-06 [1] CRAN (R 4.1.0)                     
desc             1.3.0    2021-03-05 [1] CRAN (R 4.1.0)                     
devtools       * 2.4.2    2021-06-07 [1] CRAN (R 4.1.0)                     
digest           0.6.27   2020-10-24 [1] CRAN (R 4.1.0)                     
distributional   0.2.2    2021-02-02 [1] CRAN (R 4.1.0)                     
dplyr          * 1.0.6    2021-05-05 [1] CRAN (R 4.1.0)                     
DT               0.18     2021-04-14 [1] CRAN (R 4.1.0)                     
dygraphs         1.1.1.6  2018-07-11 [1] CRAN (R 4.1.0)                     
ellipsis         0.3.2    2021-04-29 [1] CRAN (R 4.1.0)                     
emmeans          1.6.1    2021-06-01 [1] CRAN (R 4.1.0)                     
estimability     1.3      2018-02-11 [1] CRAN (R 4.1.0)                     
fansi            0.5.0    2021-05-25 [1] CRAN (R 4.1.0)                     
farver           2.1.0    2021-02-28 [1] CRAN (R 4.1.0)                     
fastmap          1.1.0    2021-01-25 [1] CRAN (R 4.1.0)                     
forcats        * 0.5.1    2021-01-27 [1] CRAN (R 4.1.0)                     
fs               1.5.0    2020-07-31 [1] CRAN (R 4.1.0)                     
gamm4            0.2-6    2020-04-03 [1] CRAN (R 4.1.0)                     
generics         0.1.0    2020-10-31 [1] CRAN (R 4.1.0)                     
ggdist           2.4.1    2021-06-10 [1] CRAN (R 4.1.0)                     
ggplot2        * 3.3.3    2020-12-30 [1] CRAN (R 4.1.0)                     
ggridges         0.5.3    2021-01-08 [1] CRAN (R 4.1.0)                     
glue             1.4.2    2020-08-27 [1] CRAN (R 4.1.0)                     
gridExtra        2.3      2017-09-09 [1] CRAN (R 4.1.0)                     
gtable           0.3.0    2019-03-25 [1] CRAN (R 4.1.0)                     
gtools           3.9.2    2021-06-06 [1] CRAN (R 4.1.0)                     
haven            2.4.1    2021-04-23 [1] CRAN (R 4.1.0)                     
hms              1.1.0    2021-05-17 [1] CRAN (R 4.1.0)                     
htmltools        0.5.1.1  2021-01-22 [1] CRAN (R 4.1.0)                     
htmlwidgets      1.5.3    2020-12-10 [1] CRAN (R 4.1.0)                     
httpuv           1.6.1    2021-05-07 [1] CRAN (R 4.1.0)                     
httr             1.4.2    2020-07-20 [1] CRAN (R 4.1.0)                     
igraph           1.2.6    2020-10-06 [1] CRAN (R 4.1.0)                     
inline           0.3.19   2021-05-31 [1] CRAN (R 4.1.0)                     
insight          0.14.1   2021-05-28 [1] CRAN (R 4.1.0)                     
jsonlite         1.7.2    2020-12-09 [1] CRAN (R 4.1.0)                     
later            1.2.0    2021-04-23 [1] CRAN (R 4.1.0)                     
lattice          0.20-44  2021-05-02 [1] CRAN (R 4.1.0)                     
lifecycle        1.0.0    2021-02-15 [1] CRAN (R 4.1.0)                     
lme4             1.1-27   2021-05-15 [1] CRAN (R 4.1.0)                     
loo              2.4.1    2021-06-12 [1] Github (stan-dev/loo@0117858)      
lubridate        1.7.10   2021-02-26 [1] CRAN (R 4.1.0)                     
magrittr       * 2.0.1    2020-11-17 [1] CRAN (R 4.1.0)                     
markdown         1.1      2019-08-07 [1] CRAN (R 4.1.0)                     
MASS             7.3-54   2021-05-03 [1] CRAN (R 4.1.0)                     
Matrix           1.3-3    2021-05-04 [1] CRAN (R 4.1.0)                     
matrixStats      0.59.0   2021-06-01 [1] CRAN (R 4.1.0)                     
memoise          2.0.0    2021-01-26 [1] CRAN (R 4.1.0)                     
mgcv             1.8-35   2021-04-18 [1] CRAN (R 4.1.0)                     
mime             0.10     2021-02-13 [1] CRAN (R 4.1.0)                     
miniUI           0.1.1.1  2018-05-18 [1] CRAN (R 4.1.0)                     
minqa            1.2.4    2014-10-09 [1] CRAN (R 4.1.0)                     
modelr           0.1.8    2020-05-19 [1] CRAN (R 4.1.0)                     
multcomp         1.4-17   2021-04-29 [1] CRAN (R 4.1.0)                     
munsell          0.5.0    2018-06-12 [1] CRAN (R 4.1.0)                     
mvtnorm          1.1-2    2021-06-07 [1] CRAN (R 4.1.0)                     
nlme             3.1-152  2021-02-04 [1] CRAN (R 4.1.0)                     
nloptr           1.2.2.2  2020-07-02 [1] CRAN (R 4.1.0)                     
parameters       0.14.0   2021-05-29 [1] CRAN (R 4.1.0)                     
pillar           1.6.1    2021-05-16 [1] CRAN (R 4.1.0)                     
pkgbuild         1.2.0    2020-12-15 [1] CRAN (R 4.1.0)                     
pkgconfig        2.0.3    2019-09-22 [1] CRAN (R 4.1.0)                     
pkgload          1.2.1    2021-04-06 [1] CRAN (R 4.1.0)                     
plyr             1.8.6    2020-03-03 [1] CRAN (R 4.1.0)                     
prettyunits      1.1.1    2020-01-24 [1] CRAN (R 4.1.0)                     
processx         3.5.2    2021-04-30 [1] CRAN (R 4.1.0)                     
projpred         2.0.2    2020-10-28 [1] CRAN (R 4.1.0)                     
promises         1.2.0.1  2021-02-11 [1] CRAN (R 4.1.0)                     
ps               1.6.0    2021-02-28 [1] CRAN (R 4.1.0)                     
purrr          * 0.3.4    2020-04-17 [1] CRAN (R 4.1.0)                     
R6               2.5.0    2020-10-28 [1] CRAN (R 4.1.0)                     
Rcpp           * 1.0.6    2021-01-15 [1] CRAN (R 4.1.0)                     
RcppParallel     5.1.4    2021-05-04 [1] CRAN (R 4.1.0)                     
readr          * 1.4.0    2020-10-05 [1] CRAN (R 4.1.0)                     
readxl           1.3.1    2019-03-13 [1] CRAN (R 4.1.0)                     
remotes          2.4.0    2021-06-02 [1] CRAN (R 4.1.0)                     
reprex           2.0.0    2021-04-02 [1] CRAN (R 4.1.0)                     
reshape2         1.4.4    2020-04-09 [1] CRAN (R 4.1.0)                     
rlang            0.4.11   2021-04-30 [1] CRAN (R 4.1.0)                     
rprojroot        2.0.2    2020-11-15 [1] CRAN (R 4.1.0)                     
rsconnect        0.8.18   2021-05-24 [1] CRAN (R 4.1.0)                     
rstan          * 2.21.2   2020-07-27 [1] CRAN (R 4.1.0)                     
rstantools       2.1.1    2020-07-06 [1] CRAN (R 4.1.0)                     
rstudioapi       0.13     2020-11-12 [1] CRAN (R 4.1.0)                     
rvest            1.0.0    2021-03-09 [1] CRAN (R 4.1.0)                     
sandwich         3.0-1    2021-05-18 [1] CRAN (R 4.1.0)                     
scales           1.1.1    2020-05-11 [1] CRAN (R 4.1.0)                     
sessioninfo      1.1.1    2018-11-05 [1] CRAN (R 4.1.0)                     
shiny            1.6.0    2021-01-25 [1] CRAN (R 4.1.0)                     
shinyjs          2.0.0    2020-09-09 [1] CRAN (R 4.1.0)                     
shinystan        2.5.0    2018-05-01 [1] CRAN (R 4.1.0)                     
shinythemes      1.2.0    2021-01-25 [1] CRAN (R 4.1.0)                     
StanHeaders    * 2.21.0-7 2020-12-17 [1] CRAN (R 4.1.0)                     
stringi          1.6.2    2021-05-17 [1] CRAN (R 4.1.0)                     
stringr        * 1.4.0    2019-02-10 [1] CRAN (R 4.1.0)                     
survival         3.2-11   2021-04-26 [1] CRAN (R 4.1.0)                     
svUnit           1.0.6    2021-04-19 [1] CRAN (R 4.1.0)                     
testthat         3.0.2    2021-02-14 [1] CRAN (R 4.1.0)                     
TH.data          1.0-10   2019-01-21 [1] CRAN (R 4.1.0)                     
threejs          0.3.3    2020-01-21 [1] CRAN (R 4.1.0)                     
tibble         * 3.1.2    2021-05-16 [1] CRAN (R 4.1.0)                     
tidybayes      * 2.3.1    2020-11-02 [1] CRAN (R 4.1.0)                     
tidyr          * 1.1.3    2021-03-03 [1] CRAN (R 4.1.0)                     
tidyselect       1.1.1    2021-04-30 [1] CRAN (R 4.1.0)                     
tidyverse      * 1.3.1    2021-04-15 [1] CRAN (R 4.1.0)                     
usethis        * 2.0.1    2021-02-10 [1] CRAN (R 4.1.0)                     
utf8             1.2.1    2021-03-12 [1] CRAN (R 4.1.0)                     
V8               3.4.2    2021-05-01 [1] CRAN (R 4.1.0)                     
vctrs            0.3.8    2021-04-29 [1] CRAN (R 4.1.0)                     
withr            2.4.2    2021-04-18 [1] CRAN (R 4.1.0)                     
xml2             1.3.2    2020-04-23 [1] CRAN (R 4.1.0)                     
xtable           1.8-4    2019-04-21 [1] CRAN (R 4.1.0)                     
xts              0.12.1   2020-09-09 [1] CRAN (R 4.1.0)                     
zoo              1.8-9    2021-03-09 [1] CRAN (R 4.1.0)                     

[1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library

I will take a look at your model later on and see what is causing this issue.

Setting that aside, moment matching and similar functionality that was previously exclusive to the rstan backend is now also available in brms models fitted with cmdstanr (Support 'log_prob' and friends for CmdStanR backend Β· Issue #1184 Β· paul-buerkner/brms Β· GitHub).

1 Like

I can run moment matching of your model on my machine. Here is my sessionInfo:

R version 4.0.4 (2021-02-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252    LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C                    LC_TIME=German_Germany.1252    

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

other attached packages:
[1] brms_2.15.9 Rcpp_1.0.6 

loaded via a namespace (and not attached):
  [1] nlme_3.1-152            matrixStats_0.58.0      xts_0.12.1             
  [4] lubridate_1.7.10        threejs_0.3.3           rstan_2.19.3           
  [7] backports_1.2.1         tools_4.0.4             utf8_1.2.1             
 [10] R6_2.5.0                DT_0.17                 DBI_1.1.1              
 [13] mgcv_1.8-33             projpred_2.0.2          colorspace_2.0-0       
 [16] withr_2.4.2             tidyselect_1.1.0        gridExtra_2.3          
 [19] prettyunits_1.1.1       processx_3.5.1          Brobdingnag_1.2-6      
 [22] emmeans_1.5.4           compiler_4.0.4          cli_2.4.0              
 [25] shinyjs_2.0.0           colourpicker_1.1.0      checkmate_2.0.0        
 [28] scales_1.1.1            dygraphs_1.1.1.6        mvtnorm_1.1-1          
 [31] ggridges_0.5.3          callr_3.5.1             stringr_1.4.0          
 [34] digest_0.6.27           StanHeaders_2.21.0-7    minqa_1.2.4            
 [37] base64enc_0.1-3         pkgconfig_2.0.3         htmltools_0.5.1.1      
 [40] lme4_1.1-26             fastmap_1.1.0           htmlwidgets_1.5.3      
 [43] rlang_0.4.10            shiny_1.6.0             generics_0.1.0         
 [46] zoo_1.8-8               crosstalk_1.1.1         gtools_3.9.2           
 [49] dplyr_1.0.5             inline_0.3.17           magrittr_2.0.1         
 [52] loo_2.4.1               bayesplot_1.8.0         Matrix_1.3-2           
 [55] munsell_0.5.0           fansi_0.4.2             abind_1.4-5            
 [58] lifecycle_1.0.0         stringi_1.5.3           MASS_7.3-53            
 [61] pkgbuild_1.2.0          plyr_1.8.6              grid_4.0.4             
 [64] parallel_4.0.4          promises_1.2.0.1        crayon_1.4.1           
 [67] miniUI_0.1.1.1          lattice_0.20-41         splines_4.0.4          
 [70] ps_1.6.0                pillar_1.6.0            igraph_1.2.6           
 [73] boot_1.3-26             estimability_1.3        markdown_1.1           
 [76] shinystan_2.5.0         codetools_0.2-18        reshape2_1.4.4         
 [79] stats4_4.0.4            rstantools_2.1.1        glue_1.4.2             
 [82] RcppParallel_5.1.0-9000 vctrs_0.3.7             nloptr_1.2.2.2         
 [85] httpuv_1.5.5            gtable_0.3.0            purrr_0.3.4            
 [88] assertthat_0.2.1        ggplot2_3.3.3           mime_0.10              
 [91] xtable_1.8-4            coda_0.19-4             later_1.1.0.1          
 [94] rsconnect_0.8.16        diffobj_0.3.3           tibble_3.1.0           
 [97] shinythemes_1.2.0       gamm4_0.2-6             statmod_1.4.35         
[100] ellipsis_0.3.1          bridgesampling_1.0-0   

I see that you’re using brms 2.15.9 (the dev version I had was 2.15.0). loo and stanhearders seem to be the versions I used. Your rstan is an older version.

So I’ve tried again. But I got the same message. Could it be sth about the operating system? Is there a way how one catch the errors from the cores to get more information?

Error : $ operator is invalid for atomic vectors
In addition: Warning message:
In parallel::mclapply(X = I, mc.cores = cores, FUN = function(i) loo_moment_match_i_fun(i)) :
  scheduled core 5 encountered error in user code, all values of the job will be affected
Error: Moment matching failed. Perhaps you did not set 'save_pars = save_pars(all = TRUE)' when fitting your model?

(and a simpler example on the same data, but without random effects again works when I run loo, just the more complex model with random effects does not)

It very likely is because brms uses different parallelization on windows and unix. I tested with a windows system but I don’t have a mac ready to try it out with that as well.

Any Mac user willing to jump in and trying it out?

@paul.buerkner - Tried testing this on a Mac. I didn’t run this on exactly the same model as @tiflo (mine is Poisson glm with varying intercepts), but was running into the same error described here (Errors with moment matching). I updated to the dev version of brms and received the same

Error : $ operator is invalid for atomic vectors
In addition: Warning message:
In parallel::mclapply(X = I, mc.cores = cores, FUN = function(i) loo_moment_match_i_fun(i)) :
  all scheduled cores encountered errors in user code
Error: Moment matching failed. Perhaps you did not set 'save_pars = save_pars(all = TRUE)' when fitting your model?

I’m running a Mac with Big Sur and the following:

R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.5.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/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] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] here_1.0.1         rstan_2.26.3       StanHeaders_2.26.3 brms_2.15.9       
[5] Rcpp_1.0.7        

loaded via a namespace (and not attached):
  [1] nlme_3.1-152         matrixStats_0.60.0   xts_0.12.1           lubridate_1.7.10    
  [5] threejs_0.3.3        rprojroot_2.0.2      backports_1.2.1      tools_4.0.5         
  [9] utf8_1.2.2           rgdal_1.5-23         R6_2.5.0             DT_0.18             
 [13] DBI_1.1.1            mgcv_1.8-36          projpred_2.0.2       colorspace_2.0-2    
 [17] sp_1.4-5             tidyselect_1.1.1     gridExtra_2.3        prettyunits_1.1.1   
 [21] processx_3.5.2       Brobdingnag_1.2-6    curl_4.3.2           compiler_4.0.5      
 [25] cli_3.0.1            shinyjs_2.0.0        colourpicker_1.1.0   checkmate_2.0.0     
 [29] scales_1.1.1         dygraphs_1.1.1.6     mvtnorm_1.1-2        ggridges_0.5.3      
 [33] callr_3.7.0          stringr_1.4.0        digest_0.6.27        minqa_1.2.4         
 [37] base64enc_0.1-3      pkgconfig_2.0.3      htmltools_0.5.1.1    lme4_1.1-27.1       
 [41] fastmap_1.1.0        htmlwidgets_1.5.3    rlang_0.4.11         rstudioapi_0.13     
 [45] shiny_1.6.0          generics_0.1.0       zoo_1.8-9            jsonlite_1.7.2      
 [49] crosstalk_1.1.1      gtools_3.9.2         dplyr_1.0.7          inline_0.3.19       
 [53] magrittr_2.0.1       loo_2.4.1            bayesplot_1.8.1      Matrix_1.3-4        
 [57] munsell_0.5.0        fansi_0.5.0          abind_1.4-5          lifecycle_1.0.0     
 [61] stringi_1.7.3        MASS_7.3-54          pkgbuild_1.2.0       plyr_1.8.6          
 [65] grid_4.0.5           parallel_4.0.5       promises_1.2.0.1     crayon_1.4.1        
 [69] miniUI_0.1.1.1       lattice_0.20-44      splines_4.0.5        ps_1.6.0            
 [73] pillar_1.6.2         igraph_1.2.6         boot_1.3-28          markdown_1.1        
 [77] shinystan_2.5.0      reshape2_1.4.4       codetools_0.2-18     stats4_4.0.5        
 [81] rstantools_2.1.1     glue_1.4.2           V8_3.4.2             RcppParallel_5.1.4  
 [85] vctrs_0.3.8          nloptr_1.2.2.2       httpuv_1.6.1         gtable_0.3.0        
 [89] purrr_0.3.4          assertthat_0.2.1     ggplot2_3.3.5        mime_0.11           
 [93] xtable_1.8-4         coda_0.19-4          later_1.2.0          rsconnect_0.8.24    
 [97] tibble_3.1.3         shinythemes_1.2.0    gamm4_0.2-6          ellipsis_0.3.2      
[101] bridgesampling_1.1-2

Thank you. Unfortunately, still unable to debug it without a Mac. It has likely something to do with how objects are passed through mclapply but I need someone else to dig into it and find out which objects are not passed correctly.

Not sure I’ve got the skills to figure that out on my own, but would be happy to give it a shot if you can give me an idea of what you’d need to know. Not sure who on the Stan team runs Macs these days (maybe @jonah?)