The following model specification works as expected with brms
through within-chain parallelization:
brm(y ~ cond + (1|Subj), data=dat, …, backend = “cmdstanr”, threads = threading(4))
It would also work fine when the measurement error for the response variable y
is incorporated into the model without using within-chain parallelization:
brm(y | se(SE, sigma = TRUE) ~ cond + (1|Subj), data=dat, …,)
However, when within-chain parallelization is invoked for the second model:
brm(y | se(SE, sigma=TRUE) ~ cond + (1|Subj), data=dat, …, backend = “cmdstanr”, threads = threading(4))
it sputters with the following:
Chain 1 Exception: Exception: normal_lpdf: Random variable has size = 710, but Scale parameter has size 11366; and they must be the same size. (in ‘/tmp/Rtmp8GdeTj/model-336f182bf4d2.stan’, line 28, column 4 to column 73) (in ‘/tmp/Rtmp8GdeTj/model-336f182bf4d2.stan’, line 28, column 4 to column 73)
Chain 1 Exception: Exception: normal_lpdf: Random variable has size = 710, but Scale parameter has size 11366; and they must be the same size. (in ‘/tmp/Rtmp8GdeTj/model-336f182bf4d2.stan’, line 28, column 4 to column 73) (in ‘/tmp/Rtmp8GdeTj/model-336f182bf4d2.stan’, line 28, column 4 to column 73)
…
Warning: Chain 1 finished unexpectedly!Warning: Chain 2 finished unexpectedly!
Warning: Chain 3 finished unexpectedly!
Warning: Chain 4 finished unexpectedly!
Warning: Use read_cmdstan_csv() to read the results of the failed chains.
Error in rstan::read_stan_csv(out$output_files()) :
csvfiles does not contain any CSV file name
Calls: brm … eval2 → eval → eval → .fun → .fit_model →
In addition: Warning messages:
1: All chains finished unexpectedly!
2: No chains finished successfully. Unable to retrieve the fit.
Execution halted