Hi,
I’m having an issue using the beta_binomial distribution.
I wrote a stan model where the outcome is modelled by a beta_binomial.
With rstan 2.19.2 it runs without any problems.
Now, I updated rstan to 2.19.3 and I’m getting on same data and model a warning about low Tail ESS.
Therefore I minimized my model to check the beta_binomial and compared the result on both versions.
data {
int<lower=0> N;
int y[N];
int group[N];
}
parameters {
real<lower=0> a[2];
real<lower=0> b[2];
}
model {
y ~ beta_binomial(60, a[group], b[group]);
a ~ exponential(0.5);
b ~ exponential(0.5);
}
generated quantities {
vector[N] ppc_y;
vector[N] log_lik;
for(i in 1:N){
log_lik[i] = beta_binomial_lpmf(y[i] | 60, a[group[i]], b[group[i]]);
ppc_y[i] = beta_binomial_rng(60, a[group[i]], b[group[i]]);
}
}
I’m using fake data.csv (16.4 KB) including 500 data points for two groups and sampling parameters are iter=2000 and chains=4.
The fit with version *.2 took ~10 sec per chain.
With version *.3 ~280 sec per chain and there are 4000 transition divergents, high R-hat values and low Bulk/Tail ESS.
Using the target += notation:
data {
int<lower=0> N;
int y[N];
int group[N];
}
parameters {
real<lower=0> a[2];
real<lower=0> b[2];
}
model {
target += beta_binomial_lpmf(y |60, a[group], b[group]);
a ~ exponential(0.5);
b ~ exponential(0.5);
}
generated quantities {
vector[N] ppc_y;
vector[N] log_lik;
for(i in 1:N){
log_lik[i] = beta_binomial_lpmf(y[i] | 60, a[group[i]], b[group[i]]);
ppc_y[i] = beta_binomial_rng(60, a[group[i]], b[group[i]]);
}
}
The result is:
2.19.2 ~12 sec
2.19.3 ~ 16 sec
Have I done anything wrong or is there an issue with the sampling statement?
Is it right that the sampling using *.3 in comparison with *.2 could take longer even with the target notation?
And regarding my first issue, is it also possible to get low ESS using version 2.19.3 where everything is fine with 2.19.2?
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)