Connection error

Please also provide the following information in addition to your question:

  • Operating System: Windows Server 2016
  • brms Version: 2.9.0

I am attempting my first brms model. I routinely run this model in rstanarm.

The code is

Preop0.stan_brmsfit <- brm(success | trials(n) ~ Age + Sex +
o.ASAPhysicalStatus +
AnxietyTScore + DepressionTScore +
Map + Worst + Average +
PhysicalFunctionTScore + SleepRawScore +
WorstSitePainLastWeek +
(1 | AnonymousInstitutionName),
data = Preop.df,
family = binomial(link = ‘logit’),
chains = 4, cores = 4, iter = 4000)

The code compiles, but then errors come when sampling starts:

Rows containing NAs were excluded from the model.Compiling the C++ model
recompiling to avoid crashing R session
Start sampling
Error in unserialize(socklist[[n]]) : error reading from connection

I have a user library that has all rstan packages within it. No rstan packages are in the system library.

I don’t see a similar question in the archives.

I don’t know how to debug.



PS sessioninfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server >= 2012 x64 (build 9200)

Matrix products: default

[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] brms_2.9.0 shinystan_2.5.0 shiny_1.3.2
[4] loo_2.1.0 cowplot_0.9.4 bayesplot_1.7.0
[7] rstanarm_2.18.2 Rcpp_1.0.1 rstan_2.18.2
[10] StanHeaders_2.18.1-10 emmeans_1.3.5.1 lmerTest_3.1-0
[13] lme4_1.1-21 Matrix_1.2-15 robustbase_0.93-5
[16] plotly_4.9.0 ggmosaic_0.2.0 skimr_1.0.7
[19] MASS_7.3-51.1 tableone_0.10.0 tables_0.8.8
[22] Hmisc_4.2-0 Formula_1.2-3 survival_2.44-1.1
[25] lattice_0.20-38 forcats_0.4.0 stringr_1.4.0
[28] dplyr_0.8.2 purrr_0.3.2 readr_1.3.1
[31] tidyr_0.8.3 tibble_2.1.3 ggplot2_3.2.0
[34] tidyverse_1.2.1 magrittr_1.5 tinytex_0.14
[37] readit_1.0.0 knitr_1.23

loaded via a namespace (and not attached):
[1] readxl_1.3.1 backports_1.1.4 plyr_1.8.4 igraph_1.2.4.1
[5] lazyeval_0.2.2 splines_3.5.3 crosstalk_1.0.0 TH.data_1.0-10
[9] rstantools_1.5.1 inline_0.3.15 digest_0.6.19 htmltools_0.3.6
[13] rsconnect_0.8.13 productplots_0.1.1 checkmate_1.9.3 cluster_2.0.7-1
[17] modelr_0.1.4 matrixStats_0.54.0 xts_0.11-2 sandwich_2.5-1
[21] prettyunits_1.0.2 colorspace_1.4-1 rvest_0.3.4 mitools_2.4
[25] haven_2.1.0 xfun_0.8 callr_3.2.0 crayon_1.3.4
[29] jsonlite_1.6 zoo_1.8-6 glue_1.3.1 gtable_0.3.0
[33] pkgbuild_1.0.3 DEoptimR_1.0-8 abind_1.4-5 scales_1.0.0
[37] mvtnorm_1.0-11 DBI_1.0.0 miniUI_0.1.1.1 viridisLite_0.3.0
[41] xtable_1.8-4 htmlTable_1.13.1 foreign_0.8-71 stats4_3.5.3
[45] survey_3.36 DT_0.7 htmlwidgets_1.3 httr_1.4.0
[49] threejs_0.3.1 RColorBrewer_1.1-2 acepack_1.4.1 pkgconfig_2.0.2
[53] nnet_7.3-12 labeling_0.3 tidyselect_0.2.5 rlang_0.4.0
[57] reshape2_1.4.3 later_0.8.0 munsell_0.5.0 cellranger_1.1.0
[61] tools_3.5.3 cli_1.1.0 generics_0.0.2 broom_0.5.2
[65] ggridges_0.5.1 evaluate_0.14 yaml_2.2.0 processx_3.3.1
[69] nlme_3.1-140 mime_0.7 xml2_1.2.0 compiler_3.5.3
[73] shinythemes_1.1.2 rstudioapi_0.10 stringi_1.4.3 ps_1.3.0
[77] Brobdingnag_1.2-6 nloptr_1.2.1 markdown_1.0 shinyjs_1.0
[81] pillar_1.4.2 bridgesampling_0.6-0 estimability_1.3 data.table_1.12.2
[85] httpuv_1.5.1 R6_2.4.0 latticeExtra_0.6-28 promises_1.0.1
[89] gridExtra_2.3 codetools_0.2-16 boot_1.3-20 colourpicker_1.0
[93] gtools_3.8.1 assertthat_0.2.1 withr_2.1.2 multcomp_1.4-10
[97] parallel_3.5.3 hms_0.4.2 grid_3.5.3 rpart_4.1-13
[101] coda_0.19-2 minqa_1.2.4 rmarkdown_1.13 numDeriv_2016.8-1.1
[105] lubridate_1.7.4 base64enc_0.1-3 dygraphs_1.1.1.6

Error in serialize(data, node$con, xdr = FALSE) :
error writing to connection

A possible issue is a crash due to exceeded memory capacity. Do the processes consume a lot of memory? Also try running with chains = 1.

Hope that helps!

P.S. Note that you can use backticks (`) and triple backticks for inline code and code blocks respectively to make your posts easier to read :-)

Setting chains = 1, cores = 1, the regression runs in about 100 seconds.

I don’t have system privileges and am not allowed access tools to show memory consumption of processes.

I have run the same code in rstan_glmer without difficulty. The dataset has about 1000 rows.

Setting cores and chains > 1 causes “R for Windows front-end has stopped working” popup window

Same connection error messages



This is usually due to some antivirus thing.