CmdStan User's Guide
Introduction
QuickStart Guide
1
CmdStan Installation
1.1
Installation via
conda
1.1.1
CmdStan install location under conda
1.2
Installation from GitHub
1.2.1
Downloading the source code
1.2.2
Building CmdStan
1.3
Checking the Stan compiler
1.4
Troubleshooting the installation
1.4.1
Common problems
1.5
C++ Toolchain
1.6
Using GNU Make
2
Example Model and Data
3
Compiling a Stan Program
3.1
Invoking the Make utility
3.2
Dependencies
3.3
Compiler errors
3.4
Troubleshooting C++ compiler or linker errors
3.5
C++ compilation and linking flags
3.5.1
Optimizing by ignoring range checks
4
MCMC Sampling
4.1
Running the sampler
4.2
Running multiple chains
4.2.1
Using the num_chains argument to run multiple chains
4.2.2
Using shell for running multiple chains
4.3
Stan CSV output file
4.4
Summarizing sampler output(s) with
stansummary
5
Optimization
6
Variational Inference
7
Generating Quantities of Interest from a Fitted Model
Reference Manual
8
Command-Line Interface Overview
8.1
Input data argument
8.2
Output control arguments
8.3
Initialize model parameters argument
8.4
Random number generator arguments
8.5
Chain identifier argument:
id
8.6
Command line help
8.7
Error messages and return codes
9
MCMC Sampling using Hamiltonian Monte Carlo
9.1
Iterations
9.2
Adaptation
9.2.1
Step size optimization configuration
9.2.2
Warmup schedule configuration
9.3
Algorithm
9.3.1
Samples from a set of fixed parameters
9.3.2
HMC samplers
9.4
Sampler diagnostic file
9.5
Examples
9.5.1
Running multiple chains with a specified RNG seed
9.5.2
Changing the default warmup and sampling iterations
9.5.3
Saving warmup draws
9.5.4
Initializing parameters
9.5.5
Specifying the metric and stepsize
9.5.6
Changing the NUTS-HMC adaptation parameters
9.5.7
Increasing the tree-depth
9.5.8
Capturing Hamiltonian diagnostics and gradients
9.5.9
Suppressing progress updates to the console
9.5.10
Everything example
10
Maximum Likelihood Estimation
10.1
Optimization algorithms
10.2
The quasi-Newton optimizers
10.3
The Newton optimizer
11
Variational Inference Algorithm: ADVI
11.1
Variational algorithms
11.2
Configuration
11.3
CSV output
12
Standalone Generate Quantities
13
Diagnosing HMC by Comparison of Gradients
14
Parallelization
14.1
Multi-threading with TBB
14.1.1
Compiling
14.1.2
Running
14.2
Multi-processing with MPI
14.2.1
Dependencies
14.2.2
Compiling
14.2.3
Running
14.3
OpenCL
14.3.1
Dependencies
14.3.2
Compiling
14.3.3
Running
CmdStan Tools
15
stanc
: Translating Stan to C++
15.1
Instantiating the
stanc
binary
15.2
The Stan compiler program
16
stansummary
: MCMC Output Analysis
16.1
Building the stansummary command
16.2
Running the
stansummary
program
16.2.1
Sampler parameters
16.2.2
Model parameters and quantities of interest
16.3
Command-line options
17
diagnose
: Diagnosing Biased Hamiltonian Monte Carlo Inferences
17.1
Building the diagnose command
17.2
Running the diagnose command
17.3
diagnose
warnings and recommendations
17.3.1
Divergent transitions after warmup
17.3.2
Maximum treedepth exceeded
17.3.3
Low E-BFMI values - sampler transitions HMC potential energy.
17.3.4
Low effective sample sizes
17.3.5
High
\(\hat{R}\)
18
print
(deprecated): MCMC Output Analysis
Appendices
19
Stan CSV File Format
19.1
CSV column names and order
19.2
MCMC sampler CSV output
19.2.1
Sampler Stan CSV output file
19.2.2
Diagnostic CSV output file
19.2.3
Profiling CSV output file
19.3
Optimization output
19.4
Variational inference output
19.5
Generate quantities outputs
19.6
Diagnose method outputs
20
JSON Format for CmdStan
20.1
Creating JSON files
20.2
JSON syntax summary
20.3
Stan data types in JSON notation
20.3.1
Empty arrays in JSON
21
RDump Format for CmdStan
21.1
Creating dump files
21.2
Scalar variables
21.3
Sequence variables
21.4
Array variables
21.5
Matrix- and vector-valued variables
21.5.1
Vector dump format
21.5.2
Matrix dump format
21.5.3
Arrays of vectors and matrices
21.6
Complex-valued variables
21.7
Integer- and real-valued variables
21.7.1
Scientific notation
21.7.2
Infinite and not-a-number values
21.8
Quoted variable names
21.9
Line breaks
21.10
BNF grammar for dump data
22
Using external C++ code
Bibliography
CmdStan User’s Guide
This is an old version,
view current version
.
CmdStan Tools
This section provides a reference for the CmdStan tools:
stanc
stansummary
diagnose
print (deprecated)