Initialization failed for gp() using brms on cluster

Dear all,
I’m trying to analyze spatially non-independent data using the gp() function in brms following chapter 13.4.1 of Statistical Rethinking Recoded. I’m using my university’s HPCC to fit the models because they are too much for my laptop to handle. However, for some reason, the initialization keeps failing even with the example on CRAN (works fine on my laptop though). Removing the gp() term stops the initialization error for all the models. I’ve tried updating rstan and brms, adjusting priors, and messing around with the inits input but still receive the error.

Any idea what I can do to fix the error?
Thanks in advance!

# simulate data using the mgcv package
dat <- mgcv::gamSim(1, n = 30, scale = 2)

# fit a simple GP model
fit1 <- brm(y ~ gp(x2), dat, chains = 2)
summary(fit1)

Compiling Stan program…
Start sampling



Chain 1: Rejecting initial value:
Chain 1: Gradient evaluated at the initial value is not finite.
Chain 1: Stan can’t start sampling from this initial value.
Chain 1:
Chain 1: Initialization between (-2, 2) failed after 100 attempts.
Chain 1: Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
[1] “Error in sampler$call_sampler(args_list[[i]]) : Initialization failed.”

Compiler: devtoolset-8
R version 4.0.3 (2020-10-10) --Need admin access to update :(
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS: /opt/r/4.0.3/intel/lib64/R/lib/libRblas.so
LAPACK: /opt/r/4.0.3/intel/lib64/R/lib/libRlapack.so

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

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

loaded via a namespace (and not attached):
[1] nlme_3.1-149 matrixStats_0.58.0 xts_0.12.1
[4] threejs_0.3.3 rstan_2.21.2 backports_1.2.1
[7] tools_4.0.3 utf8_1.1.4 R6_2.5.0
[10] DT_0.18 DBI_1.1.1 mgcv_1.8-33
[13] projpred_2.0.2 colorspace_2.0-0 withr_2.4.1
[16] tidyselect_1.1.0 gridExtra_2.3 prettyunits_1.1.1
[19] processx_3.5.2 Brobdingnag_1.2-6 compiler_4.0.3
[22] curl_4.3.1 cli_2.5.0 shinyjs_2.0.0
[25] colourpicker_1.1.0 scales_1.1.1 dygraphs_1.1.1.6
[28] mvtnorm_1.1-1 ggridges_0.5.3 callr_3.7.0
[31] stringr_1.4.0 digest_0.6.27 StanHeaders_2.21.0-7
[34] minqa_1.2.4 base64enc_0.1-3 pkgconfig_2.0.3
[37] htmltools_0.5.1.1 lme4_1.1-27 fastmap_1.1.0
[40] htmlwidgets_1.5.3 rlang_0.4.10 shiny_1.6.0
[43] generics_0.1.0 zoo_1.8-9 jsonlite_1.7.2
[46] crosstalk_1.1.1 gtools_3.8.2 dplyr_1.0.5
[49] inline_0.3.18 magrittr_2.0.1 loo_2.4.1.9000
[52] bayesplot_1.8.0 Matrix_1.2-18 munsell_0.5.0
[55] fansi_0.4.2 abind_1.4-5 lifecycle_1.0.0
[58] stringi_1.5.3 nleqslv_3.3.2 MASS_7.3-53
[61] pkgbuild_1.2.0 plyr_1.8.6 grid_4.0.3
[64] parallel_4.0.3 promises_1.2.0.1 crayon_1.4.1
[67] miniUI_0.1.1.1 lattice_0.20-41 splines_4.0.3
[70] ps_1.6.0 pillar_1.6.1 igraph_1.2.6
[73] boot_1.3-25 markdown_1.1 shinystan_2.5.0
[76] codetools_0.2-16 reshape2_1.4.4 stats4_4.0.3
[79] rstantools_2.1.1 glue_1.4.2 V8_3.4.2
[82] RcppParallel_5.1.4 vctrs_0.3.8 nloptr_1.2.2.2
[85] httpuv_1.6.1 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.2.0
[94] rsconnect_0.8.17 tibble_3.1.0 shinythemes_1.2.0
[97] gamm4_0.2-6 ellipsis_0.3.2 bridgesampling_1.1-2

Can you try with either latest cmdstanr (you can set options(brms.backend = "cmdstanr")) or with the latest rstan via Repository for distributing (some) stan-dev R packages | r-packages (the CRAN version is a bit behind for stupid reasons)… It is well possible there was some numerical issue in the Stan math library that got fixed in the mean time…

Best of luck with your model!

1 Like