wwiecek / baggr

R package for Bayesian meta-analysis models, using Stan
GNU General Public License v3.0
46 stars 12 forks source link

Why divergent transitions under mu & tau model? #95

Closed wwiecek closed 3 years ago

wwiecek commented 3 years ago
# Generate IPD dataset based on 8 schools -----
# Means will differ of course because we plug in original SEs
schools_ipd <- data.frame()
N <- c(rep(10, 4), rep(20, 4))
for(i in 1:8){
  bsl <- rnorm(1, 0, 5)

  x <- rnorm(N[i])
  x <- (x-mean(x))/sd(x)
  x <- x*schools$se[i]*sqrt(N[i])/1.41 + schools$tau[i]

  y <- rnorm(N[i])
  y <- (y-mean(y))/sd(y)
  y <- y*schools$se[i]*sqrt(N[i])/1.41

  schools_ipd <- rbind(schools_ipd,
                       data.frame(group = schools$group[i], outcome = bsl + x, treatment = 1),
                       # This is just so that we don't trip off prepare_ma:
                       data.frame(group = schools$group[i], outcome = bsl + y, treatment = 0))
}

summ <- prepare_ma(schools_ipd)
baggr(summ)

I get 100 DTs here, even though the model is very basic -- why?

wwiecek commented 3 years ago

@rmeager when you work on baggr next do you mind having a look?

rmeager commented 3 years ago

This always had DTs, just like the old Rubin model example in stan always had DTs -- mea culpa on this. Inspecting the model code, it looks like we didnt re-center this model when we re-centered the Rubin model last year (or 2019), so it could just be that?

wwiecek commented 3 years ago

Good call, I'll check if there is a simple fix and report back here

wwiecek commented 3 years ago

the way i was checking this was actually a bit wrong, not the model itself; my current centered parameterisation idea is giving stupid results so it needs more work; I'm leaving this open because that model needs re-writing for various other reasons, but for the record, the current version should work fine too

wwiecek commented 3 years ago

This has now been fixed with rewritten mu&tau model.