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 using Pathfinder
7
Variational Inference using ADVI
8
Generating Quantities of Interest from a Fitted Model
Reference Manual
9
Command-Line Interface Overview
9.1
Input data argument
9.2
Output control arguments
9.3
Initialize model parameters argument
9.4
Random number generator arguments
9.5
Chain identifier argument:
id
9.6
Command line help
9.7
Error messages and return codes
10
MCMC Sampling using Hamiltonian Monte Carlo
10.1
Iterations
10.2
Adaptation
10.2.1
Step size optimization configuration
10.2.2
Warmup schedule configuration
10.3
Algorithm
10.3.1
Samples from a set of fixed parameters
10.3.2
HMC samplers
10.4
Sampler diagnostic file
10.5
Multiple chains in one executable
10.6
Examples - older parallelism
10.6.1
Running multiple chains with a specified RNG seed
10.6.2
Changing the default warmup and sampling iterations
10.6.3
Saving warmup draws
10.6.4
Initializing parameters
10.6.5
Specifying the metric and stepsize
10.6.6
Changing the NUTS-HMC adaptation parameters
10.6.7
Increasing the tree-depth
10.6.8
Capturing Hamiltonian diagnostics and gradients
10.6.9
Suppressing progress updates to the console
10.6.10
Everything example
11
Maximum Likelihood Estimation
11.1
Jacobian adjustments
11.2
Optimization algorithms
11.3
The quasi-Newton optimizers
11.4
The Newton optimizer
12
Pathfinder Method for Approximate Bayesian Inference
12.1
Pathfinder Configuration
12.2
L-BFGS Configuration
12.3
Multi-path Pathfinder CSV files
12.4
Single-path Pathfinder Outputs.
13
Variational Inference Algorithm: ADVI
13.1
Variational algorithms
13.2
Configuration
13.3
CSV output
14
Standalone Generate Quantities
15
Laplace sampling
15.1
Configuration
15.2
CSV output
15.3
Example
16
Extracting log probabilities and gradients for diagnostics
16.1
Configuration
16.2
CSV output
17
Diagnosing HMC by Comparison of Gradients
18
Parallelization
18.1
Multi-threading with TBB
18.1.1
Compiling
18.1.2
Running
18.2
Multi-processing with MPI
18.2.1
Dependencies
18.2.2
Compiling
18.2.3
Running
18.3
OpenCL
18.3.1
Dependencies
18.3.2
Compiling
18.3.3
Running
CmdStan Tools
19
stanc
: Translating Stan to C++
19.1
Instantiating the
stanc
binary
19.2
The Stan compiler program
20
stansummary
: MCMC Output Analysis
20.1
Building the stansummary command
20.2
Running the
stansummary
program
20.2.1
Sampler parameters
20.2.2
Model parameters and quantities of interest
20.3
Command-line options
21
diagnose
: Diagnosing Biased Hamiltonian Monte Carlo Inferences
21.1
Building the diagnose command
21.2
Running the diagnose command
21.3
diagnose
warnings and recommendations
21.3.1
Divergent transitions after warmup
21.3.2
Maximum treedepth exceeded
21.3.3
Low E-BFMI values - sampler transitions HMC potential energy.
21.3.4
Low effective sample sizes
21.3.5
High
\(\hat{R}\)
22
print
(deprecated): MCMC Output Analysis
Appendices
23
Stan CSV File Format
23.1
CSV column names and order
23.2
MCMC sampler CSV output
23.2.1
Sampler Stan CSV output file
23.2.2
Diagnostic CSV output file
23.2.3
Profiling CSV output file
23.3
Optimization output
23.4
Variational inference output
23.5
Generate quantities outputs
23.6
Diagnose method outputs
24
JSON Format for CmdStan
24.1
Creating JSON files
24.2
JSON syntax summary
24.3
Stan data types in JSON notation
24.3.1
Empty arrays in JSON
25
RDump Format for CmdStan
25.1
Creating dump files
25.2
Scalar variables
25.3
Sequence variables
25.4
Array variables
25.5
Matrix- and vector-valued variables
25.5.1
Vector dump format
25.5.2
Matrix dump format
25.5.3
Arrays of vectors and matrices
25.6
Complex-valued variables
25.7
Integer- and real-valued variables
25.7.1
Scientific notation
25.7.2
Infinite and not-a-number values
25.8
Quoted variable names
25.9
Line breaks
25.10
BNF grammar for dump data
26
Using external C++ code
26.1
Derivative specializations
26.2
Special functions: RNGs, distributions, editing
target
Bibliography
CmdStan User’s Guide
This is an old version,
view current version
.
Appendices
This section contains the following appendices:
Stan CSV File Format
JSON format
RDump data format
Using external C++ code from within a Stan program