Diagnostics¶
The Diagnostics page provides comprehensive MCMC diagnostics and posterior analysis with ArviZ integration for Bayesian inference results.
Overview¶
The Diagnostics page offers:
ArviZ Plots: Seven diagnostic plot types for MCMC quality assessment
Goodness-of-Fit Metrics: R-squared, R-hat, ESS, divergences with color coding
Model Comparison: Side-by-side comparison of multiple Bayesian results
Export: Save diagnostic plots in publication-quality formats
Accessing Diagnostics¶
From the main window:
Run Bayesian inference on the Bayesian tab
Click Show Diagnostics or navigate to the Diagnostics tab
Select a model from the dropdown if multiple results exist
ArviZ Plot Types¶
The Diagnostics page provides seven ArviZ diagnostic plot types via tabbed interface:
Trace Plot¶
Purpose: Visualize MCMC chain behavior and posterior distributions.
Left panel: Posterior density (KDE)
Right panel: Chain trace over iterations
What to look for:
Chains should overlap (good mixing)
No trends or drift
Stationary behavior after warmup
Forest Plot¶
Purpose: Compare credible intervals across parameters.
Point estimates with HDI (Highest Density Interval)
Default 95% credibility level
Customize HDI via
hdi_probparameter
What to look for:
Intervals that don’t overlap zero (significant parameters)
Relative uncertainty between parameters
Compare credible widths
Pair Plot¶
Purpose: Visualize parameter correlations and divergences.
Scatter plots of parameter pairs
Marginal distributions on diagonal
Divergence markers (red points)
What to look for:
High correlations indicate reparameterization may help
Divergences clustered in regions indicate model issues
Funnel shapes suggest non-centered parameterization needed
Energy Plot¶
Purpose: NUTS-specific energy diagnostics.
Marginal energy distribution
Energy transition distribution
What to look for:
Distributions should overlap significantly
Large separation indicates exploration problems
Autocorrelation Plot¶
Purpose: Assess chain mixing via autocorrelation.
Autocorrelation function (ACF) per parameter
Decay pattern across lags
What to look for:
Quick decay to zero (good mixing)
Slow decay indicates low ESS
Rank Plot¶
Purpose: Rank statistics for convergence assessment.
Rank histogram per chain
Should be approximately uniform
What to look for:
Uniform distribution across chains
Non-uniform indicates chain issues
ESS Plot¶
Purpose: Effective Sample Size visualization.
ESS per parameter
Comparison across parameters
What to look for:
ESS > 400 for reliable inference
Low ESS indicates need for more samples
Goodness-of-Fit Metrics¶
The metrics panel displays:
Metric |
Description |
Good Values |
|---|---|---|
R-squared |
Coefficient of determination |
> 0.95 |
Chi-squared |
Sum of squared residuals |
Lower is better |
MPE (%) |
Mean Percentage Error |
< 5% |
WAIC |
Widely Applicable Information Criterion |
Lower is better |
LOO |
Leave-One-Out cross-validation |
Lower is better |
ESS (min) |
Minimum Effective Sample Size |
> 400 |
R-hat (max) |
Maximum Gelman-Rubin statistic |
< 1.01 |
Divergences |
Number of divergent transitions |
0 |
Color Coding¶
Metrics are color-coded for quick assessment:
Green: Good (R-hat < 1.01, ESS > 400, Divergences = 0)
Yellow: Warning (R-hat < 1.1, ESS > 100)
Red: Problem (R-hat > 1.1, ESS < 100, Divergences > 0)
Model Comparison¶
Compare multiple Bayesian results:
Run Bayesian inference on multiple models
Go to Diagnostics page
View Model Comparison panel
Click Refresh Comparison
Comparison metrics include:
WAIC (Widely Applicable Information Criterion)
LOO (Leave-One-Out cross-validation)
ELPD (Expected Log Pointwise Predictive Density)
Stacking weights
Exporting Plots¶
Export diagnostic plots:
Select the plot tab you want to export
Click Export [Plot Type] Plot
Choose format:
PNG: Raster format (150-300 DPI)
PDF: Vector format (publication quality)
SVG: Vector format (editable)
Select save location
Click Save
Troubleshooting¶
High R-hat (> 1.1)¶
Chains haven’t converged:
Increase
num_warmup(try 2000-4000)Increase
num_samples(try 4000-8000)Check for multimodality in trace plot
Try different initial values
Low ESS (< 400)¶
Insufficient effective samples:
Increase
num_samplesCheck autocorrelation plot
Consider reparameterization
Increase
num_chains
Divergences (> 0)¶
Numerical integration issues:
Check pair plot for divergence patterns
Try
target_accept_prob=0.95(stricter)Reparameterize model (non-centered)
Adjust priors to avoid extreme regions
No Results Available¶
If “No Bayesian Results” message appears:
Run Bayesian inference on Bayesian tab first
Ensure inference completed successfully
Check that model name matches
Best Practices¶
Always check all diagnostic plots before trusting results
Run multiple chains (4+) for reliable R-hat
Use NLSQ warm-start for faster convergence
Report R-hat and ESS with published results
Export ArviZ InferenceData for reproducibility
Compare models using WAIC/LOO, not R-squared alone
See Also¶
Bayesian Inference - Bayesian inference configuration
Exporting - Exporting results and plots
Bayesian Inference - Advanced Bayesian topics