Skip to content

CLI Tool

The mcmc binary is included in the package (dist/cli/index.cjs). Install globally or use via npx.

bash
npm install -g mcmc-visualizer
# or
npx mcmc-visualizer <command> [file] [options]

Commands

mcmc summary  <file>   Full statistics table (mean, std, mcse, ess, rhat, ...)
mcmc diagnose <file>   Convergence diagnostics (rhat, splitRhat, ess bulk/tail, mcse, geweke)
mcmc rhat     <file>   R-hat and split R-hat only
mcmc ess      <file>   ESS bulk, tail, per-draw, and count
mcmc convert  <file>   Convert to JSON
mcmc plot     <file>   Output a Plotly JSON spec

Options

OptionValuesDescription
--formattable (default), jsonOutput format
--vars a,b,ccomma-separatedFilter to specific variables
--chains c1,c2comma-separatedFilter to specific chains
--warmup NintegerDiscard first N draws
--fromturing-csv, stan-csv, mcmcchains-json, arviz-jsonSkip auto-detection
--tojsonExport format
--typetrace, density, rank, …Plot type for plot command
--themedark, lightTheme for plot specs
--height, --widthintegerPlot dimensions in pixels
--stdinflagRead from stdin instead of a file
--out filepathWrite output to file instead of stdout
--help, -hflagPrint help
--version, -vflagPrint package version

Examples

bash
# Print summary table
mcmc summary posterior.json

# Get JSON diagnostics, filter variables with rhat > 1.01
mcmc diagnose output.csv --format json | jq '.[] | select(.rhat > 1.01)'

# Discard 200 warm-up draws, show only two variables
mcmc summary chains.csv --warmup 200 --vars mu,sigma

# Generate a Plotly trace plot spec for a specific variable
mcmc plot posterior.json --type trace --vars mu --theme light > spec.json

# Pipe from stdin
cat chains.csv | mcmc ess --stdin

# Filter chains and write output to file
mcmc diagnose run.json --chains chain#1,chain#2 --out diagnostics.json

Convergence status codes

The diagnose command shows a status field per variable:

StatusCondition
OKR-hat < 1.01
WARNR-hat 1.01–1.1
FAILR-hat ≥ 1.1 or undefined

Released under the MIT License.