Interactive explorer
Four methods, one posterior
The four algorithms from the assignment, ported line by line from R and run in your browser. With the original settings they reproduce R’s output exactly (and, in As submitted mode, the numbers printed in the 2023 report); change the seed or the tuning to see how each road behaves.
The same four R functions, fed the data the assignment describes: 7 doses, 10 patients each, and logit p = β₀ + β₁·dose. All four roads should arrive at nearly the same posterior.
Model and data
What every method is fitting
Seven grouped binomial observations, one per dose level, with a flat prior so the posterior is proportional to the likelihood. Two coefficients: an intercept and the change in log-odds of improvement per unit of dose.
| dose | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|---|
| improved | 3 | 5 | 4 | 4 | 7 | 6 | 8 |
| not improved | 7 | 5 | 6 | 6 | 3 | 4 | 2 |
| proportion | 0.3 | 0.5 | 0.4 | 0.4 | 0.7 | 0.6 | 0.8 |
Each method runs in a Web Worker with R’s Mersenne-Twister seeded at 90125.
Laplace approximation
approximation
Waiting…
Metropolis-Hastings
sampler
Waiting…
Hamiltonian Monte Carlo
sampler
Waiting…
Expectation propagation
approximation
Waiting…
Marginal posteriors
Four estimates of β₁
- Laplace approximation
- Metropolis-Hastings
- Hamiltonian Monte Carlo
- Expectation propagation
| Method | mean | sd | 95% interval | ESS |
|---|---|---|---|---|
| Laplace | … | … | … | |
| MH | … | … | … | |
| HMC | … | … | … | |
| EP | … | … | … |
Intervals are 2.5% and 97.5% quantiles of the draws for MH and HMC, and mean ± 1.96 sd for the Gaussian approximations. ESS is coda::effectiveSize, reported as is: it can exceed the number of draws when successive HMC draws are negatively correlated.
Mixing
Trace plots for β₁
Metropolis-Hastings
Hamiltonian Monte Carlo
Joint posterior
β₀ against β₁
- Laplace
- MH
- HMC
- EP
What it means
Probability of improvement by dose
- Laplace
- MH
- HMC
- EP
Every number, every coefficient
| Coefficient | Method | mean | sd | 2.5% | 50% | 97.5% | ESS |
|---|---|---|---|---|---|---|---|
| β₀ (Intercept) | Laplace | … | … | … | … | … | … |
| MH | … | … | … | … | … | … | |
| HMC | … | … | … | … | … | … | |
| EP | … | … | … | … | … | … | |
| β₁ dose | Laplace | … | … | … | … | … | … |
| MH | … | … | … | … | … | … | |
| HMC | … | … | … | … | … | … | |
| EP | … | … | … | … | … | … |