Hi,
I’m having some troubles trying to come up with map_rect version of a simple linear mixed model, such as y ~ cond + (cond||subj)
I used brms to build the Stan code, and then modified it according to how I understood map_rect should be implemented, and strangely enough, when I ran the multi threading version I get CIs that are relatively close to the brms’s values, but all the 95% CI are just above or below the true value of the parameters. And while the brms model has quite low n_eff (maybe @paul.buerkner wants to check what’s going on), the multi threading version has a much higher n_eff. (And I assume they should be the same, or am I wrong?)
This is the output of the brms model:
# Inference for Stan model: lmm_nc_brms.
# 3 chains, each with iter=2000; warmup=1000; thin=1;
# post-warmup draws per chain=1000, total post-warmup draws=3000.
# mean se_mean sd 2.75% 97.5% n_eff Rhat
# b_Intercept 6.01 0 0.01 5.99 6.03 107 1.01
# b[1] 0.49 0 0.01 0.47 0.51 104 1.05
# sigma 0.10 0 0.00 0.10 0.10 4714 1.00
# sd_1[1] 0.10 0 0.01 0.08 0.11 285 1.00
# sd_1[2] 0.10 0 0.01 0.09 0.11 242 1.02
# Samples were drawn using NUTS(diag_e) at Fri Nov 30 06:44:33 2018.
# For each parameter, n_eff is a crude measure of effective sample size,
# and Rhat is the potential scale reduction factor on split chains (at
# convergence, Rhat=1).
(The true values are 6 ,.5, .1,.1,.1)
This is the output of the multi-threading version:
# Inference for Stan model: lmm_nc.
# 3 chains, each with iter=2000; warmup=1000; thin=1;
# post-warmup draws per chain=1000, total post-warmup draws=3000.
# mean se_mean sd 2.75% 97.5% n_eff Rhat
# b_Intercept 6.01 0 0.00 6.00 6.01 4775 1
# b[1] 0.49 0 0.00 0.49 0.49 4146 1
# sigma 0.17 0 0.00 0.16 0.17 4097 1
# sd_1[1] 0.03 0 0.02 0.00 0.09 1117 1
# sd_1[2] 0.03 0 0.02 0.00 0.09 1182 1
# Samples were drawn using NUTS(diag_e) at Fri Nov 30 06:52:32 2018.
# For each parameter, n_eff is a crude measure of effective sample size,
# and Rhat is the potential scale reduction factor on split chains (at
# convergence, Rhat=1).
I’m attaching the R code that I used to generate the fake data, the brms model that I used as a basis, and my attempt to build a model that uses multi threading. I would really appreciate to get feedback so that I understand where it went wrong.
lmm_multi_threading.R (2.0 KB)
lmm_nc_brms.stan (1.8 KB)
lmm_nc.stan (3.5 KB)
Thanks!
Bruno