- Operating System: mac OS 10.12.6 (16G29)
- rstanarm Version: 2.17.2

I am running stan_glmer with the same model and the same data, just changing the algorithm argument from “Sampling” to “meanfield”. There is a bug with the intercept returned with “meanfield”: the second intercept is exactly identical the first one, and then all the other intercepts are shifted by one (the second one is in place of the third one, etc).

Here is my code:

```
# library(rethinking)
# data("reedfrogs")
reedfrogs <- read.csv("https://raw.githubusercontent.com/rmcelreath/rethinking/master/data/reedfrogs.csv", sep=";")
d <- reedfrogs
d$tank <- 1:nrow(d)
library(rstanarm)
reedarm <- stan_glmer(cbind(surv, density-surv)~(1|tank), data=d, algorithm = "sampling", family=binomial())
reedarmvb <- stan_glmer(cbind(surv, density-surv)~(1|tank), data=d, algorithm = "meanfield", family=binomial())
# see in the data.frame how the values are shifted
data.frame(sampling=colMeans(as.matrix(reedarm))[2:8], meanfield=colMeans(as.matrix(reedarmvb))[2:8])
```

Which shows:

```
sampling meanfield
b[(Intercept) tank:1] 0.7550621 0.8797813
b[(Intercept) tank:2] 1.7484607 0.8797813 # DUPLICATED!
b[(Intercept) tank:3] -0.3773396 1.4443334
b[(Intercept) tank:4] 1.7010447 -0.2794685
b[(Intercept) tank:5] 0.7895597 1.5234424
b[(Intercept) tank:6] 0.7589158 0.7587912
b[(Intercept) tank:7] 1.6665793 0.7248997
# same with plots
plot(colMeans(as.matrix(reedarmvb))[2:29], colMeans(as.matrix(reedarm))[2:29])
# Approximately equal intercepts between the two methods once shift by one !
plot(colMeans(as.matrix(reedarmvb))[2:29], colMeans(as.matrix(reedarm))[1:28])
```

SessionInfo():

```
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.6
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] bindrcpp_0.2.2 rstanarm_2.17.2 Rcpp_0.12.17 rethinking_1.59
[5] rstan_2.17.3 StanHeaders_2.17.2 ggplot2_3.0.0
loaded via a namespace (and not attached):
[1] mvtnorm_1.0-6 lattice_0.20-35 zoo_1.8-2 gtools_3.5.0
[5] assertthat_0.2.0 digest_0.6.15 mime_0.5 R6_2.2.2
[9] plyr_1.8.4 ggridges_0.5.0 stats4_3.3.2 coda_0.19-1
[13] colourpicker_1.0 pillar_1.2.3 rlang_0.2.1 lazyeval_0.2.1
[17] minqa_1.2.4 miniUI_0.1.1.1 nloptr_1.0.4 Matrix_1.2-12
[21] DT_0.4 labeling_0.3 splines_3.3.2 shinythemes_1.1.1
[25] shinyjs_1.0 lme4_1.1-17 stringr_1.3.1 htmlwidgets_1.2
[29] loo_2.0.0 igraph_1.1.2 munsell_0.5.0 shiny_1.1.0
[33] httpuv_1.4.3 pkgconfig_2.0.1 base64enc_0.1-3 rstantools_1.5.0
[37] htmltools_0.3.6 tidyselect_0.2.4 tibble_1.4.2 gridExtra_2.3
[41] codetools_0.2-15 threejs_0.3.1 matrixStats_0.53.1 dplyr_0.7.5
[45] later_0.7.3 MASS_7.3-50 grid_3.3.2 nlme_3.1-128
[49] xtable_1.8-2 gtable_0.2.0 magrittr_1.5 scales_0.5.0
[53] stringi_1.2.2 reshape2_1.4.3 promises_1.0.1 dygraphs_1.1.1.4
[57] xts_0.10-1 tools_3.3.2 glue_1.2.0 shinystan_2.5.0
[61] markdown_0.8 purrr_0.2.5 crosstalk_1.0.0 survival_2.42-3
[65] rsconnect_0.8.8 inline_0.3.15 colorspace_1.3-2 bayesplot_1.5.0
[69] bindr_0.1.1
```

I tried updated rstan and rstanarm before bugging you, but I still did not manage to install the latest version from source. It needs the last version of Matrix, which can be only installed from source and I am still stuck with the error:

```
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Matrix.so] Error 1
```

In any case, I hope it is still a useful bug report, and I would appreciate any help.

And thank you for your great software!

Arnaud