# Initialization failed for gp() using brms on cluster

**URL:** <https://discourse.mc-stan.org/t/initialization-failed-for-gp-using-brms-on-cluster/23201>\
**Category:** brms\
**Tags:** initialization, gaussian-process, brms\
**Created:** [June 26, 2021, 3:02pm UTC](https://discourse.mc-stan.org/t/initialization-failed-for-gp-using-brms-on-cluster/23201 "2021-06-26T15:02:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Linum\_grandiflorum](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/linum_grandiflorum/32/12164_2.png) [@Linum\_grandiflorum](https://discourse.mc-stan.org/u/Linum_grandiflorum)\
**Post date:** [June 26, 2021, 3:02pm UTC](https://discourse.mc-stan.org/t/initialization-failed-for-gp-using-brms-on-cluster/23201/1 "2021-06-26T15:02:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![martinmodrak](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/martinmodrak/32/133_2.png) [@martinmodrak](https://discourse.mc-stan.org/u/martinmodrak)\
**Post date:** [July 2, 2021, 8:48am UTC](https://discourse.mc-stan.org/t/initialization-failed-for-gp-using-brms-on-cluster/23201/2 "2021-07-02T08:48:49Z")

</div>

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](http://mc-stan.org/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!
