Hi all, firstly thank you all for your hard work on Stan and your contribution to Bayesian inference. I’m just getting started myself, and I am trying to understand the constraints of what I can and can’t do.
Suppose we have a situation where a school gives one student ten different tests, each on completely different subjects. Each test gets a percentage score between 0.0 and 1.0. The tests are known to be very hard, so we expect the score distribution across all of these tests to be right-tailed.
In taking obscene liberties following this guide https://vioshyvo.github.io/Bayesian_inference/hierarchical-models.html, I wanted to see if I can simulate the Bayesian posterior by treating each test’s variance as unknown, but with an uninformative half-Cauchy distribution that (under my understanding) basically says “the score will move, but not much”.
My goal is to generate Bayesian MCMC draws from those modeling parameters and for each draw be able to know the simulated test results for test1, test2, test3, etc (i.e. generate a vector of scores that index 1 scores correspond to test 1, idx 2 -> test2 etc). Unfortunately, when I attempt to do this I get heaps of warnings.
Using the toy data / input:
school <- list(J = 10, y = c(0.0, 0.7, 0.25, 0.3, 0.7, 0.4, 0.1, 0.15, 0.3, 0.35))
fit <- stan('schools2.stan', data = school, iter = 1e4, chains = 4, control = list(adapt_delta = 0.9999))
Where schools2.stan
is:
data {
int<lower=0> J;
real y[J];
}
parameters {
real mu;
real<lower=0> tau;
real<lower=0> dvar[J];
real<lower=0, upper=1> theta[J];
}
model {
tau ~ cauchy(0,0.2);
dvar ~ cauchy(0,0.2);
theta ~ normal(mu, dvar);
y ~ normal(theta, tau);
}
> check_hmc_diagnostics(fit)
Divergences:
215 of 20000 iterations ended with a divergence (1.075%).
Try increasing 'adapt_delta' to remove the divergences.
Tree depth:
5219 of 20000 iterations saturated the maximum tree depth of 10 (26.095%).
Try increasing 'max_treedepth' to avoid saturation.
Energy:
E-BFMI indicated no pathological behavior.
If I ditch the horse because I can’t mount the saddle and try to just use something else like brms, I still get heaps (532) of divergent transitions:
d <- read.csv("test_data.csv", header=T)
mod <- brm(scores ~ (1 | tests), d, family=skew_normal())
Where test_data.csv
corresponds to:
tests,scores
test1,0.0
test2,0.7
test3,0.25
test4,0.3
test5,0.7
test6,0.4
test7,0.1
test8,0.15
test9,0.3
test10,0.35
Am I doing anything obviously wrong? Thanks in advance.