### Verify CmdStan Installation with Bernoulli Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_25/cmdstan-guide/cmdstan-installation.html This sequence of commands verifies a successful CmdStan installation. It compiles the Bernoulli example model, runs a sampling process with provided data, checks the output file, and then uses `stansummary` to summarize the parameter estimates. Windows users should use `mingw32-make` for the compilation step. ```Shell # compile the example make examples/bernoulli/bernoulli # on Windows use mingw32-make # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.json # default output written to file `output.csv`, # default num_samples is 1000, output file should have approx. 1050 lines ls -l output.csv # run the `bin/stansummary` utility to summarize parameter estimates bin/stansummary output.csv ``` -------------------------------- ### Build Example Bernoulli Stan Model Source: https://github.com/stan-dev/docs/blob/master/docs/2_24/cmdstan-guide/cmdstan-installation.html Shows how to compile the example Bernoulli Stan model located at examples/bernoulli/bernoulli.stan into an executable using the make command. ```bash make examples/bernoulli/bernoulli ``` -------------------------------- ### Verify CmdStan Installation with Bernoulli Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_31/cmdstan-guide/cmdstan-installation.html Steps to confirm a successful CmdStan installation by compiling and running an example Stan program (Bernoulli model) and summarizing its output. This checks the functionality of the compiler, sampler, and summary utility. ```Linux/macOS Shell make examples/bernoulli/bernoulli ./examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.json ls -l output.csv bin/stansummary output.csv ``` ```Windows Shell mingw32-make examples/bernoulli/bernoulli.exe ./examples/bernoulli/bernoulli.exe sample data file=examples/bernoulli/bernoulli.data.json bin/stansummary.exe output.csv ``` -------------------------------- ### Verify CmdStan Installation with Bernoulli Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_26/cmdstan-guide/cmdstan-installation.html A series of commands to check the CmdStan installation by compiling and running an example Stan program (Bernoulli model), processing data, and summarizing the output. ```Shell # compile the example make examples/bernoulli/bernoulli # on Windows use mingw32-make # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.json # default output written to file `output.csv`, # default num_samples is 1000, output file should have approx. 1050 lines ls -l output.csv # run the `bin/stansummary utility to summarize parameter estimates bin/stansummary output.csv ``` -------------------------------- ### Verify CmdStan Installation with Bernoulli Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_30/cmdstan-guide/cmdstan-installation.html Steps to confirm CmdStan is correctly installed and functional by compiling an example Stan program, fitting it to data, and summarizing the results using `stansummary`. The example uses Bernoulli data with 2 successes out of 10 trials. ```Shell # compile the example make examples/bernoulli/bernoulli # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.json # default output written to file `output.csv`, # default num_samples is 1000, output file should have approx. 1050 lines ls -l output.csv # run the `bin/stansummary utility to summarize parameter estimates bin/stansummary output.csv ``` ```Windows Batch # compile the example mingw32-make examples/bernoulli/bernoulli.exe # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli.exe sample data file=examples/bernoulli/bernoulli.data.json # run the `bin/stansummary.exe utility to summarize parameter estimates bin/stansummary.exe output.csv ``` -------------------------------- ### Build Bernoulli Model Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_25/cmdstan-guide/cmdstan-installation.html This command builds the executable for the Bernoulli model example located at 'examples/bernoulli/bernoulli.stan'. It compiles the Stan program into a runnable binary, preparing it for execution. ```Bash make examples/bernoulli/bernoulli ``` -------------------------------- ### CmdStan Bernoulli Model Example Workflow Source: https://github.com/stan-dev/docs/blob/master/docs/2_33/cmdstan-guide/cmdstan-installation.html Provides a complete workflow for the Bernoulli example model, illustrating the typical steps from building the model executable to running the sampling process with data and finally summarizing the generated samples using the `stansummary` utility. ```Shell > make examples/bernoulli/bernoulli ``` ```Shell > examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R ``` ```Shell > bin/stansummary output.csv ``` -------------------------------- ### Verify CmdStan Installation with Bernoulli Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_29/cmdstan-guide/cmdstan-installation.html This snippet demonstrates how to compile and run a basic Stan model (Bernoulli) and summarize its output using `stansummary`, thereby verifying the CmdStan installation. The example uses provided data specifying 2 successes out of 10 trials. ```Shell (Linux/macOS) # compile the example make examples/bernoulli/bernoulli # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.json # default output written to file `output.csv`, # default num_samples is 1000, output file should have approx. 1050 lines ls -l output.csv # run the `bin/stansummary` utility to summarize parameter estimates bin/stansummary output.csv ``` ```Shell (Windows) # compile the example mingw32-make examples/bernoulli/bernoulli.exe # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli.exe sample data file=examples/bernoulli/bernoulli.data.json # run the `bin/stansummary.exe` utility to summarize parameter estimates bin/stansummary.exe output.csv ``` -------------------------------- ### Compile CmdStan Example Model Source: https://github.com/stan-dev/docs/blob/master/docs/2_24/cmdstan-guide/cmdstan-installation.html Compile an example Stan program, such as the Bernoulli model, to create an executable. This is a crucial step to verify the CmdStan installation. ```shell make examples/bernoulli/bernoulli ``` -------------------------------- ### CmdStan Bernoulli Model End-to-End Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_32/cmdstan-guide/cmdstan-installation.html Provides a complete workflow example for the Bernoulli model, demonstrating how to build the model executable, run the sampling process with data, and then use `bin/stansummary` to analyze the generated samples from the output CSV file. ```Shell make examples/bernoulli/bernoulli ``` ```Shell examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R ``` ```Shell bin/stansummary output.csv ``` -------------------------------- ### Verify CmdStan Installation on Windows Source: https://github.com/stan-dev/docs/blob/master/docs/2_27/cmdstan-guide/cmdstan-installation.html Commands to compile and run an example Stan model, then summarize its output, to confirm a successful CmdStan installation on Windows. ```Windows Batch # compile the example mingw32-make examples/bernoulli/bernoulli.exe # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli.exe sample data file=examples/bernoulli/bernoulli.data.json # run the `bin/stansummary.exe` utility to summarize parameter estimates bin/stansummary.exe output.csv ``` -------------------------------- ### Build Bernoulli Stan Model Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_30/cmdstan-guide/cmdstan-installation.html This command compiles the `examples/bernoulli/bernoulli.stan` model into an executable, making it ready for simulation or sampling. ```Shell make examples/bernoulli/bernoulli ``` -------------------------------- ### Bernoulli Model Example: Build, Run, and Summarize Source: https://github.com/stan-dev/docs/blob/master/docs/2_27/cmdstan-guide/cmdstan-installation.html A complete workflow demonstrating how to build a Stan model, run it with sample data, and then use `bin/stansummary` to analyze the generated output samples. ```Shell make examples/bernoulli/bernoulli examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R bin/stansummary output.csv ``` -------------------------------- ### Verify CmdStan Installation on Linux/macOS Source: https://github.com/stan-dev/docs/blob/master/docs/2_27/cmdstan-guide/cmdstan-installation.html Commands to compile and run an example Stan model, then summarize its output, to confirm a successful CmdStan installation on Linux or macOS. ```Shell # compile the example make examples/bernoulli/bernoulli # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.json # default output written to file `output.csv`, # default num_samples is 1000, output file should have approx. 1050 lines ls -l output.csv # run the `bin/stansummary` utility to summarize parameter estimates bin/stansummary output.csv ``` -------------------------------- ### Verify CmdStan Installation on Windows Source: https://github.com/stan-dev/docs/blob/master/docs/2_33/cmdstan-guide/cmdstan-installation.html Steps to confirm a successful CmdStan installation on Windows. This involves compiling an example Bernoulli model, fitting it to provided data, and summarizing parameter estimates using `stansummary.exe`. ```Windows Command Prompt # compile the example mingw32-make examples/bernoulli/bernoulli.exe # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli.exe sample data file=examples/bernoulli/bernoulli.data.json # run the `bin/stansummary.exe utility to summarize parameter estimates bin/stansummary.exe output.csv ``` -------------------------------- ### Run CmdStan Example Model with Data Source: https://github.com/stan-dev/docs/blob/master/docs/2_24/cmdstan-guide/cmdstan-installation.html Execute the compiled Bernoulli example model, passing sample data from a JSON file. This command performs a sampling run and generates output. ```shell ./examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.json ``` -------------------------------- ### CmdStan Bernoulli Model Example Workflow Source: https://github.com/stan-dev/docs/blob/master/docs/2_26/cmdstan-guide/cmdstan-installation.html Illustrates a complete workflow for a Stan Bernoulli model, from building the model executable to running the sampler with data and analyzing the output using `stansummary`. ```Shell make examples/bernoulli/bernoulli ``` ```Shell examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R ``` ```Shell bin/stansummary output.csv ``` -------------------------------- ### Run Example Bernoulli Stan Model with Data Source: https://github.com/stan-dev/docs/blob/master/docs/2_24/cmdstan-guide/cmdstan-installation.html Demonstrates how to execute the compiled Bernoulli Stan model to sample from the posterior, specifying a data file (examples/bernoulli/bernoulli.data.R) for the simulation. ```bash examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R ``` -------------------------------- ### CmdStan User's Guide Navigation Structure Source: https://github.com/stan-dev/docs/blob/master/docs/2_34/cmdstan-guide/installation.html Outlines the hierarchical navigation for the CmdStan User's Guide, including sections on getting started, running CmdStan (MCMC, optimization, variational inference, etc.), and various tools and utilities like `stanc` and `stansummary`. ```APIDOC CmdStan User’s Guide: Version: 2.34 Getting Started: - CmdStan Installation: ../cmdstan-guide/installation.html - Example Model and Data: ../cmdstan-guide/example_model_data.html - Compiling a Stan Program: ../cmdstan-guide/compiling_stan_programs.html - Parallelization: ../cmdstan-guide/parallelization.html Running CmdStan: - Command-Line Interface Overview: ../cmdstan-guide/command_line_options.html - MCMC Sampling using Hamiltonian Monte Carlo: ../cmdstan-guide/mcmc_config.html - Optimization: ../cmdstan-guide/optimize_config.html - Pathfinder Method for Approximate Bayesian Inference: ../cmdstan-guide/pathfinder_config.html - Variational Inference using ADVI: ../cmdstan-guide/variational_config.html - Generating Quantities of Interest from a Fitted Model: ../cmdstan-guide/generate_quantities_config.html - Laplace sampling: ../cmdstan-guide/laplace_sample_config.html - Extracting log probabilities and gradients for diagnostics: ../cmdstan-guide/log_prob_config.html - Diagnosing HMC by Comparison of Gradients: ../cmdstan-guide/diagnose_config.html Tools and Utilities: - `stanc`: Translating Stan to C++: ../cmdstan-guide/stanc.html - `stansummary`: MCMC Output Analysis: ../cmdstan-guide/stansummary.html - `diagnose`: Diagnosing Biased Hamiltonian Monte Carlo Inferences: ../cmdstan-guide/diagnose_utility.html - `print` (deprecated): MCMC Output Analysis: ../cmdstan-guide/print.html Appendices: - Stan CSV File Format: ../cmdstan-guide/stan_csv_apdx.html - JSON Format for CmdStan: ../cmdstan-guide/json_apdx.html ``` -------------------------------- ### Verify CmdStan Installation on Linux/macOS Source: https://github.com/stan-dev/docs/blob/master/docs/2_33/cmdstan-guide/cmdstan-installation.html Steps to confirm a successful CmdStan installation on Linux and macOS. This involves compiling an example Bernoulli model, fitting it to provided data, checking the output file, and summarizing parameter estimates using `stansummary`. ```Shell # compile the example make examples/bernoulli/bernoulli # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.json # default output written to file `output.csv`, # default num_samples is 1000, output file should have approx. 1050 lines ls -l output.csv # run the `bin/stansummary utility to summarize parameter estimates bin/stansummary output.csv ``` -------------------------------- ### CmdStan Bernoulli Model: Build, Run, and Analyze Workflow Source: https://github.com/stan-dev/docs/blob/master/docs/2_31/cmdstan-guide/cmdstan-installation.html This example demonstrates a full workflow for the Bernoulli model, including building the model executable, running a sampling process with specified data, and summarizing the generated samples using `bin/stansummary`. ```Shell make examples/bernoulli/bernoulli ``` ```Shell examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R ``` ```Shell bin/stansummary output.csv ``` -------------------------------- ### Displaying CmdStan Make Help Output Source: https://github.com/stan-dev/docs/blob/master/docs/2_31/cmdstan-guide/cmdstan-installation.html Invoking `make` without arguments prints a comprehensive help message for CmdStan. This output details various build targets, configuration options, and an example workflow, serving as a quick reference for users. ```Shell > make # on Windows use mingw32-make -------------------------------------------------------------------------------- CmdStan v2.23.0 help Build CmdStan utilities: > make build This target will: 1. Install the Stan compiler bin/stanc from stanc3 binaries. 2. Build the print utility bin/print (deprecated; will be removed in v3.0) 3. Build the stansummary utility bin/stansummary 4. Build the diagnose utility bin/diagnose 5. Build all libraries and object files compile and link an executable Stan program Note: to build using multiple cores, use the -j option to make, e.g., for 4 cores: > make build -j4 Build a Stan program: Given a Stan program at foo/bar.stan, build an executable by typing: > make foo/bar This target will: 1. Install the Stan compiler (bin/stanc), as needed. 2. Use the Stan compiler to generate C++ code, foo/bar.hpp. 3. Compile the C++ code using cc . to generate foo/bar Additional make options: STANCFLAGS: defaults to "". These are extra options passed to bin/stanc when generating C++ code. If you want to allow undefined functions in the Stan program, either add this to make/local or the command line: STANCFLAGS = --allow_undefined USER_HEADER: when STANCFLAGS has --allow_undefined, this is the name of the header file that is included. This defaults to "user_header.hpp" in the directory of the Stan program. Example - bernoulli model: examples/bernoulli/bernoulli.stan 1. Build the model: > make examples/bernoulli/bernoulli 2. Run the model: > examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R 3. Look at the samples: > bin/stansummary output.csv Clean CmdStan: Remove the built CmdStan tools: > make clean-all -------------------------------------------------------------------------------- ``` -------------------------------- ### Verify CmdStan Installation on Windows Source: https://github.com/stan-dev/docs/blob/master/docs/2_32/cmdstan-guide/cmdstan-installation.html Execute a series of commands to verify the CmdStan installation on Windows. This involves compiling an example Stan program, fitting it to provided data, and summarizing parameter estimates using `stansummary.exe`. ```MinGW # compile the example mingw32-make examples/bernoulli/bernoulli.exe # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli.exe sample data file=examples/bernoulli/bernoulli.data.json # run the `bin/stansummary.exe` utility to summarize parameter estimates bin/stansummary.exe output.csv ``` -------------------------------- ### Verify CmdStan Installation on Linux/macOS Source: https://github.com/stan-dev/docs/blob/master/docs/2_32/cmdstan-guide/cmdstan-installation.html Execute a series of commands to verify the CmdStan installation on Linux and macOS. This includes compiling an example Stan program, fitting it to provided data, listing the output file, and summarizing parameter estimates using `stansummary`. ```Shell # compile the example make examples/bernoulli/bernoulli # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.json # default output written to file `output.csv`, # default num_samples is 1000, output file should have approx. 1050 lines ls -l output.csv # run the `bin/stansummary` utility to summarize parameter estimates bin/stansummary output.csv ``` -------------------------------- ### Verify CmdStan Installation on Linux/macOS Source: https://github.com/stan-dev/docs/blob/master/docs/2_28/cmdstan-guide/cmdstan-installation.html A series of commands to confirm a successful CmdStan installation on Linux or macOS. This involves compiling an example Bernoulli model, fitting it to provided data, and summarizing the parameter estimates using the stansummary utility. ```Shell # compile the example make examples/bernoulli/bernoulli # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.json # default output written to file `output.csv`, # default num_samples is 1000, output file should have approx. 1050 lines ls -l output.csv # run the `bin/stansummary` utility to summarize parameter estimates bin/stansummary output.csv ``` -------------------------------- ### Verify CmdStan Installation on Windows Source: https://github.com/stan-dev/docs/blob/master/docs/2_28/cmdstan-guide/cmdstan-installation.html A series of commands to confirm a successful CmdStan installation on Windows. This involves compiling an example Bernoulli model, fitting it to provided data, and summarizing the parameter estimates using the stansummary.exe utility. ```Windows Batch # compile the example mingw32-make examples/bernoulli/bernoulli.exe # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli.exe sample data file=examples/bernoulli/bernoulli.data.json # run the `bin/stansummary.exe` utility to summarize parameter estimates bin/stansummary.exe output.csv ``` -------------------------------- ### Run Bernoulli Stan Model Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_30/cmdstan-guide/cmdstan-installation.html Execute the compiled Bernoulli model to perform sampling, providing the necessary data from `examples/bernoulli/bernoulli.data.R`. The output will typically be saved to `output.csv`. ```Shell examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R ``` -------------------------------- ### Run Bernoulli Model Example with Data Source: https://github.com/stan-dev/docs/blob/master/docs/2_25/cmdstan-guide/cmdstan-installation.html This command executes the compiled Bernoulli model, running the HMC sampler. It specifies to use the 'sample' method and provides input data from 'examples/bernoulli/bernoulli.data.R' for the simulation. ```Bash examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R ``` -------------------------------- ### Navigate to CmdStan example directory Source: https://github.com/stan-dev/docs/blob/master/docs/2_35/cmdstan-guide/mcmc_config.html Instructions to change the current directory to the `bernoulli` example within the CmdStan installation and list its contents to verify the presence of necessary model and data files. ```Shell > cd examples/bernoulli > ls bernoulli bernoulli.data.json bernoulli.data.R bernoulli.stan ``` -------------------------------- ### Verify CmdStan Installation Source: https://github.com/stan-dev/docs/blob/master/docs/cmdstan-guide/installation.html Steps to verify a successful CmdStan installation by compiling an example model, running a simulation, and summarizing results with `stansummary`. Includes platform-specific commands for Linux/macOS and Windows. ```Shell # compile the example make examples/bernoulli/bernoulli # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli sample\ data file=examples/bernoulli/bernoulli.data.json # default output written to file `output.csv`, # default num_samples is 1000, output file should have approx. 1050 lines wc -l output.csv # run the `bin/stansummary` utility to summarize parameter estimates bin/stansummary output.csv ``` ```Shell # compile the example make examples/bernoulli/bernoulli.exe # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli.exe sample data file=examples/bernoulli/bernoulli.data.json # run the `bin/stansummary.exe` utility to summarize parameter estimates bin/stansummary.exe output.csv ``` -------------------------------- ### Verify CmdStan Installation with Bernoulli Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_35/cmdstan-guide/installation.html Steps to confirm a successful CmdStan installation by compiling and running a Bernoulli example model. This includes fitting the model to sample data, checking the output file, and summarizing parameter estimates using `stansummary`. ```Bash # compile the example make examples/bernoulli/bernoulli # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli sample\ data file=examples/bernoulli/bernoulli.data.json # default output written to file `output.csv`, # default num_samples is 1000, output file should have approx. 1050 lines ls -l output.csv # run the `bin/stansummary utility to summarize parameter estimates bin/stansummary output.csv ``` ```Batch # compile the example make examples/bernoulli/bernoulli.exe # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli.exe sample data file=examples/bernoulli/bernoulli.data.json # run the `bin/stansummary.exe utility to summarize parameter estimates bin/stansummary.exe output.csv ``` -------------------------------- ### Build, Run, and Summarize Bernoulli Stan Model Example Source: https://github.com/stan-dev/docs/blob/master/docs/cmdstan-guide/installation.html Provides a step-by-step example for building, executing, and analyzing the output of a Bernoulli Stan model. Includes commands for compilation, sampling with data, and summarizing results using `stansummary`. ```Bash make examples/bernoulli/bernoulli examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R bin/stansummary output.csv ``` -------------------------------- ### Install a specific CmdStan version via Conda Source: https://github.com/stan-dev/docs/blob/master/docs/2_29/cmdstan-guide/cmdstan-installation.html To install a particular version of CmdStan, append '=VERSION' to the installation command. For example, to install version 2.27.0. ```bash conda install -c conda-forge cmdstan=2.27.0 ``` -------------------------------- ### General Steps to Build CmdStan Source: https://github.com/stan-dev/docs/blob/master/docs/2_24/cmdstan-guide/cmdstan-installation.html Outlines the standard procedure for building CmdStan after downloading a release or cloning the repository. It involves changing to the CmdStan home directory and running the make build command. ```bash cd make build ``` -------------------------------- ### Verifying CmdStan Installation with Bernoulli Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_36/cmdstan-guide/installation.html This set of commands verifies the CmdStan installation by compiling and running an example Bernoulli model. It demonstrates how to fit the model to provided data, check the output file size (on Linux/macOS), and summarize parameter estimates using the stansummary utility. ```Shell (Linux/macOS) # compile the example make examples/bernoulli/bernoulli # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli sample\ data file=examples/bernoulli/bernoulli.data.json # default output written to file `output.csv`, # default num_samples is 1000, output file should have approx. 1050 lines wc -l output.csv # run the `bin/stansummary utility to summarize parameter estimates bin/stansummary output.csv ``` ```Shell (Windows) # compile the example make examples/bernoulli/bernoulli.exe # fit to provided data (results of 10 trials, 2 out of 10 successes) ./examples/bernoulli/bernoulli.exe sample data file=examples/bernoulli/bernoulli.data.json # run the `bin/stansummary.exe utility to summarize parameter estimates bin/stansummary.exe output.csv ``` -------------------------------- ### Install CmdStan into Existing Conda Environment Source: https://github.com/stan-dev/docs/blob/master/docs/2_30/cmdstan-guide/cmdstan-installation.html Use this command to install the 'cmdstan' package into an already existing conda environment. It fetches CmdStan and its dependencies from the 'conda-forge' channel, integrating them into your current setup. ```Bash conda install -c conda-forge cmdstan ``` -------------------------------- ### Install CmdStan into Existing Conda Environment Source: https://github.com/stan-dev/docs/blob/master/docs/2_31/cmdstan-guide/cmdstan-installation.html To add CmdStan to an already established Conda environment, use this command. It installs the `cmdstan` package and its required dependencies without creating a new environment, integrating CmdStan into your current setup. ```Shell conda install -c conda-forge cmdstan ``` -------------------------------- ### Building CmdStan from Source Source: https://github.com/stan-dev/docs/blob/master/docs/2_36/cmdstan-guide/installation.html This snippet shows the basic commands to navigate to the CmdStan home directory and initiate the build process using the makefile. This compiles the command-line interface and supporting C++ libraries, preparing the CmdStan utilities for use. ```Shell cd make build ``` -------------------------------- ### Install CmdStan into an existing Conda environment Source: https://github.com/stan-dev/docs/blob/master/docs/2_32/cmdstan-guide/cmdstan-installation.html Use this command to install the latest release of the 'cmdstan' package into an already existing conda environment. It fetches CmdStan and its dependencies from the 'conda-forge' channel, integrating it with your current environment setup. ```Shell conda install -c conda-forge cmdstan ``` -------------------------------- ### Install NVIDIA Drivers and CUDA Toolkit on Ubuntu Source: https://github.com/stan-dev/docs/blob/master/docs/2_27/cmdstan-guide/parallelization.html This command sequence updates package lists and installs the NVIDIA GPU driver and CUDA Toolkit on Ubuntu. The driver version (`460` in the example) should be replaced with the latest available at the time of installation. ```Bash sudo apt update sudo apt install nvidia-driver-460 nvidia-cuda-toolkit ``` -------------------------------- ### Build and Run Bernoulli Model with CmdStan Source: https://github.com/stan-dev/docs/blob/master/docs/2_28/cmdstan-guide/cmdstan-installation.html Demonstrates the workflow for compiling a Stan model, executing it with sample data, and summarizing the generated output using CmdStan tools. ```Shell make examples/bernoulli/bernoulli examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R bin/stansummary output.csv ``` -------------------------------- ### Install clinfo Tool on Ubuntu Source: https://github.com/stan-dev/docs/blob/master/docs/2_27/cmdstan-guide/parallelization.html This command installs the `clinfo` tool on Ubuntu, which is used to verify the presence of OpenCL-enabled devices and their runtimes. It's a crucial step for debugging OpenCL setups. ```Bash sudo apt-get install clinfo ``` -------------------------------- ### Clone and Build CmdStan from GitHub Source: https://github.com/stan-dev/docs/blob/master/docs/2_24/cmdstan-guide/cmdstan-installation.html Details the sequence of commands to clone the CmdStan GitHub repository recursively (including submodules), navigate into the directory, and then build the project. This is for users who want to work with the current stable development version. ```bash git clone https://github.com/stan-dev/cmdstan.git --recursive cd cmdstan make build ``` -------------------------------- ### Display CmdStan Make Utility Help Message Source: https://github.com/stan-dev/docs/blob/master/docs/2_24/cmdstan-guide/cmdstan-installation.html Invoking `make` without any arguments in the `` directory displays a comprehensive help message. This output lists the main build targets and their functionalities, including installing the Stan compiler, building utilities like `print`, `stansummary`, and `diagnose`, and compiling libraries for Stan programs. ```Makefile make -------------------------------------------------------------------------------- CmdStan v2.23.0 help Build CmdStan utilities: > make build This target will: 1. Install the Stan compiler bin/stanc from stanc3 binaries. 2. Build the print utility bin/print (deprecated; will be removed in v3.0) 3. Build the stansummary utility bin/stansummary 4. Build the diagnose utility bin/diagnose 5. Build all libraries and object files compile and link an executable Stan program ``` -------------------------------- ### Workflow for Building, Running, and Summarizing a Stan Bernoulli Model Source: https://github.com/stan-dev/docs/blob/master/docs/2_36/cmdstan-guide/installation.html A step-by-step guide to compile, execute, and analyze samples from the example Bernoulli model provided in the Stan documentation. It covers building the model, running sampling, and summarizing the output. ```Shell make examples/bernoulli/bernoulli examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R bin/stansummary output.csv ``` -------------------------------- ### Install CmdStan with Conda into an Existing Environment Source: https://github.com/stan-dev/docs/blob/master/docs/2_33/cmdstan-guide/cmdstan-installation.html Use this command to add the 'cmdstan' package and its dependencies to an already existing conda environment. This avoids creating a new environment if you prefer to manage CmdStan within an existing setup. ```Bash conda install -c conda-forge cmdstan ``` -------------------------------- ### Build CmdStan from Source Source: https://github.com/stan-dev/docs/blob/master/docs/2_25/cmdstan-guide/cmdstan-installation.html This command sequence navigates to the CmdStan home directory and initiates the build process, which compiles necessary C++ libraries and instantiates CmdStan utilities. On Windows, `mingw32-make` should be used instead of `make`. ```Shell cd make build # on Windows use mingw32-make ``` -------------------------------- ### Installing NVIDIA OpenCL/CUDA Toolkit on Ubuntu Source: https://github.com/stan-dev/docs/blob/master/docs/2_28/cmdstan-guide/parallelization.html These commands update package lists and install the NVIDIA GPU driver and CUDA Toolkit on Ubuntu. This setup is essential to enable OpenCL support for NVIDIA GPUs when running Stan models. ```Bash sudo apt update sudo apt install nvidia-driver-460 nvidia-cuda-toolkit ``` -------------------------------- ### CmdStan Bernoulli Model Build and Run Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_35/cmdstan-guide/installation.html This example demonstrates the complete workflow for a Bernoulli model in CmdStan, from building the executable using 'make' to running the sampling process and summarizing the results with 'stansummary'. ```Bash make examples/bernoulli/bernoulli examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R bin/stansummary output.csv ``` -------------------------------- ### Install NVIDIA GPU Driver and CUDA Toolkit on Ubuntu Linux Source: https://github.com/stan-dev/docs/blob/master/docs/2_36/cmdstan-guide/parallelization.html These commands update package lists and install the NVIDIA GPU driver (version 460 as an example) and the NVIDIA CUDA Toolkit on Ubuntu. This is required for OpenCL support on NVIDIA GPUs. ```bash sudo apt update sudo apt install nvidia-driver-460 nvidia-cuda-toolkit ``` -------------------------------- ### Clone and Build CmdStan GitHub Repository Source: https://github.com/stan-dev/docs/blob/master/docs/2_28/cmdstan-guide/cmdstan-installation.html Instructions for cloning the CmdStan repository from GitHub, including its submodules (Stan and Math libraries), and then building the CmdStan interface. This ensures all necessary components are assembled for development. ```Shell git clone https://github.com/stan-dev/cmdstan.git --recursive cd cmdstan make build # on Windows use mingw32-make ``` -------------------------------- ### Navigate to CmdStan example directory and list contents Source: https://github.com/stan-dev/docs/blob/master/docs/cmdstan-guide/mcmc_config.html Demonstrates how to change into the `examples/bernoulli` directory and list its contents, showing the Stan program, data files, and executable. ```bash cd examples/bernoulli ls bernoulli bernoulli.data.json bernoulli.data.R bernoulli.stan ``` -------------------------------- ### Change Directory to CmdStan Bernoulli Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_25/cmdstan-guide/mcmc-intro.html Navigates the command line to the `examples/bernoulli` directory within the CmdStan installation. This directory typically contains the Stan program and input data files necessary for running the Bernoulli model example. ```Bash cd examples/bernoulli ``` -------------------------------- ### Create New Conda Environment for CmdStan Source: https://github.com/stan-dev/docs/blob/master/docs/2_31/cmdstan-guide/cmdstan-installation.html This command initializes a new Conda environment named 'stan' and proceeds to download and install the `cmdstan` package. It also includes all necessary dependencies, such as a C++ compiler and toolchain, ensuring a complete setup for CmdStan usage. ```Shell conda create -n stan -c conda-forge cmdstan ``` -------------------------------- ### Display CmdStan Make Help Message Source: https://github.com/stan-dev/docs/blob/master/docs/2_33/cmdstan-guide/cmdstan-installation.html Shows the comprehensive help output when `make` is invoked without arguments. This message provides an overview of CmdStan's build system, including available targets for building utilities, compiling Stan programs, and cleaning the project. ```Shell > make # on Windows use mingw32-make -------------------------------------------------------------------------------- CmdStan v2.23.0 help Build CmdStan utilities: > make build This target will: 1. Install the Stan compiler bin/stanc from stanc3 binaries. 2. Build the print utility bin/print (deprecated; will be removed in v3.0) 3. Build the stansummary utility bin/stansummary 4. Build the diagnose utility bin/diagnose 5. Build all libraries and object files compile and link an executable Stan program Note: to build using multiple cores, use the -j option to make, e.g., for 4 cores: > make build -j4 Build a Stan program: Given a Stan program at foo/bar.stan, build an executable by typing: > make foo/bar This target will: 1. Install the Stan compiler (bin/stanc), as needed. 2. Use the Stan compiler to generate C++ code, foo/bar.hpp. 3. Compile the C++ code using cc . to generate foo/bar Additional make options: STANCFLAGS: defaults to "". These are extra options passed to bin/stanc when generating C++ code. If you want to allow undefined functions in the Stan program, either add this to make/local or the command line: STANCFLAGS = --allow_undefined USER_HEADER: when STANCFLAGS has --allow_undefined, this is the name of the header file that is included. This defaults to "user_header.hpp" in the directory of the Stan program. Example - bernoulli model: examples/bernoulli/bernoulli.stan 1. Build the model: > make examples/bernoulli/bernoulli 2. Run the model: > examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R 3. Look at the samples: > bin/stansummary output.csv Clean CmdStan: Remove the built CmdStan tools: > make clean-all -------------------------------------------------------------------------------- ``` -------------------------------- ### Bernoulli Model Example Workflow Source: https://github.com/stan-dev/docs/blob/master/docs/2_34/cmdstan-guide/installation.html This sequence of commands demonstrates a complete workflow for the provided Bernoulli model example. It covers building the model executable, running the sampling process with specified data, and finally summarizing the generated samples using the `stansummary` utility. ```Bash make examples/bernoulli/bernoulli ``` ```Bash examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R ``` ```Bash bin/stansummary output.csv ``` -------------------------------- ### Install NVIDIA GPU Driver and CUDA Toolkit on Ubuntu Source: https://github.com/stan-dev/docs/blob/master/docs/2_32/cmdstan-guide/parallelization.html These commands update package lists and install the NVIDIA GPU driver (version 460 as an example) and the NVIDIA CUDA Toolkit on Ubuntu. These are crucial dependencies for enabling OpenCL support on NVIDIA GPUs. ```Shell sudo apt update sudo apt install nvidia-driver-460 nvidia-cuda-toolkit ``` -------------------------------- ### Build CmdStan Source: https://github.com/stan-dev/docs/blob/master/docs/cmdstan-guide/installation.html Navigate to the CmdStan home directory and run the `make build` command to compile the CmdStan utilities and necessary C++ libraries. ```Shell cd make build ``` -------------------------------- ### Navigate to CmdStan example directory Source: https://github.com/stan-dev/docs/blob/master/docs/2_32/cmdstan-guide/mcmc-intro.html This command changes the current working directory to the `examples/bernoulli` subdirectory within the CmdStan installation, where the Stan program and input data are located. ```Shell cd examples/bernoulli ``` -------------------------------- ### CmdStan Command-Line Utilities Overview Source: https://github.com/stan-dev/docs/blob/master/docs/2_27/cmdstan-guide/cmdstan-installation.html Provides an overview of the core executable programs included with CmdStan, detailing their purpose and functionality. ```APIDOC stanc: Description: The Stan compiler, which translates Stan language to C++. stansummary: Description: A basic posterior analysis tool. It processes output files from Stan's HMC sampler and reports statistics like mean, standard deviation, percentiles, effective number of samples, and R-hat values. diagnose: Description: A basic sampler diagnostic tool that checks for indications that the HMC sampler was unable to sample from the full posterior. ``` -------------------------------- ### Incorrect GNU-Make Invocation Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_25/cmdstan-guide/cmdstan-installation.html Demonstrates the error messages encountered when attempting to invoke the CmdStan Makefile from a directory other than ``, highlighting the dependency on relative paths within the Makefile. ```Shell make -f ~/github/stan-dev/cmdstan/makefile /Users/mitzi/github/stan-dev/cmdstan/makefile:58: make/stanc: No such file or directory /Users/mitzi/github/stan-dev/cmdstan/makefile:59: make/program: No such file or directory /Users/mitzi/github/stan-dev/cmdstan/makefile:60: make/tests: No such file or directory /Users/mitzi/github/stan-dev/cmdstan/makefile:61: make/command: No such file or directory make: *** No rule to make target `make/command'. Stop. ``` -------------------------------- ### Build CmdStan with Multiple Cores Source: https://github.com/stan-dev/docs/blob/master/docs/2_24/cmdstan-guide/cmdstan-installation.html Demonstrates how to use the -j option with make to leverage multiple CPU cores for faster compilation of CmdStan, for example, using 4 cores. ```bash make build -j4 ``` -------------------------------- ### CmdStan Command Line Help (`help`, `help-all`) Source: https://github.com/stan-dev/docs/blob/master/docs/2_29/cmdstan-guide/command-line-interface-overview.html Describes CmdStan's built-in help mechanisms. The `help` command displays top-level inference methods and configuration options, while `help-all` shows the entire argument tree. This provides users with a quick reference for available commands and arguments. ```CmdStan > ./bernoulli help Usage: ./bernoulli ... ... ... Begin by selecting amongst the following inference methods and diagnostics, sample Bayesian inference with Markov Chain Monte Carlo optimize Point estimation variational Variational inference diagnose Model diagnostics generate_quantities Generate quantities of interest Or see help information with help Prints help help-all Prints entire argument tree Additional configuration available by specifying id Unique process identifier data Input data options init Initialization method: "x" initializes randomly between [-x, x], "0" initializes to 0, anything else identifies a file of values random Random number configuration output File output options ``` -------------------------------- ### Build, Run, and Summarize Bernoulli Model Source: https://github.com/stan-dev/docs/blob/master/docs/2_29/cmdstan-guide/cmdstan-installation.html Illustrates the complete workflow for a Stan model: compiling the model using `make`, executing the compiled model with sample data, and then using `stansummary` to analyze the generated output samples. ```Shell make examples/bernoulli/bernoulli ``` ```Shell examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R ``` ```Shell bin/stansummary output.csv ``` -------------------------------- ### Compile Stan Program with OpenCL Support Source: https://github.com/stan-dev/docs/blob/master/docs/2_25/cmdstan-guide/cmdstan-installation.html Example of compiling a Stan program (`my_program.stan`) with OpenCL (GPU) support by setting the `STAN_OPENCL` Makefile variable to `TRUE` during the `make` command invocation. ```Shell make STAN_OPENCL=TRUE ../my_dir/my_program ``` -------------------------------- ### Build CmdStan with Parallel Cores Source: https://github.com/stan-dev/docs/blob/master/docs/2_24/cmdstan-guide/cmdstan-installation.html Utilize multiple CPU cores to speed up the CmdStan build process by providing the '-j' option to the 'make' command. This example builds on 4 cores. ```shell make -j4 build ``` -------------------------------- ### Change Directory to CmdStan Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_31/cmdstan-guide/mcmc-intro.html This command changes the current working directory to the 'examples/bernoulli' subdirectory within the CmdStan installation, where the Stan program and input data are located. ```Bash cd examples/bernoulli ``` -------------------------------- ### Building CmdStan on Linux/macOS and Windows Source: https://github.com/stan-dev/docs/blob/master/docs/2_34/cmdstan-guide/installation.html This command navigates to the CmdStan home directory and initiates the build process. On Windows, `mingw32-make` is used instead of `make`. This step compiles all necessary C++ libraries and instantiates CmdStan utilities. ```Bash cd make build ``` ```Windows Command Prompt cd mingw32-make build ``` -------------------------------- ### Change Directory to CmdStan Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_28/cmdstan-guide/mcmc-intro.html This command changes the current working directory to the `examples/bernoulli` subdirectory within the CmdStan installation, where the Stan program and input data are typically located for execution. ```Bash cd examples/bernoulli ``` -------------------------------- ### Clone CmdStan Repository with Submodules Source: https://github.com/stan-dev/docs/blob/master/docs/2_27/cmdstan-guide/cmdstan-installation.html Instructions for cloning the CmdStan GitHub repository using the `--recursive` flag to ensure all necessary submodules (stan, math) are initialized and updated. This is followed by building CmdStan. ```Git git clone https://github.com/stan-dev/cmdstan.git --recursive cd cmdstan make build # on Windows use mingw32-make ``` -------------------------------- ### Change directory to CmdStan example Source: https://github.com/stan-dev/docs/blob/master/docs/2_27/cmdstan-guide/mcmc-intro.html This command navigates the terminal to the `examples/bernoulli` directory within the CmdStan installation. This is a prerequisite step before running the Stan program, as it ensures the executable and data files are accessible. ```bash cd examples/bernoulli ``` -------------------------------- ### CmdStan Make Options Reference Source: https://github.com/stan-dev/docs/blob/master/docs/cmdstan-guide/installation.html Documentation for various options that can be passed to the `make` command when building Stan programs, influencing compiler behavior, header inclusion, versioning, and performance optimizations. ```APIDOC Make Options: STANCFLAGS: Type: string Default: "" Description: Extra options passed to bin/stanc when generating C++ code. Example: --allow_undefined. USER_HEADER: Type: string Default: "user_header.hpp" Description: Name of the header file included when STANCFLAGS has --allow_undefined. Defaults to "user_header.hpp" in the Stan program directory. STANC3_VERSION: Type: string Description: When set, uses that tagged version specified; otherwise, downloads the nightly version. STAN_CPP_OPTIMS: Type: boolean Description: Turns on additional compiler flags for performance. STAN_NO_RANGE_CHECKS: Type: boolean Description: Removes the range checks from the model for performance. ``` -------------------------------- ### Set 32-bit Build Flag in CmdStan Local Makefile Source: https://github.com/stan-dev/docs/blob/master/docs/2_25/cmdstan-guide/cmdstan-installation.html Example of setting the `BIT=32` Makefile variable in the `/make/local` file to ensure all CmdStan programs and Stan models compile for a 32-bit machine. ```Makefile BIT=32 ``` -------------------------------- ### CmdStan Sampler Full Configuration Example Source: https://github.com/stan-dev/docs/blob/master/docs/2_33/cmdstan-guide/mcmc-config.html This example provides a comprehensive template for calling the CmdStan sampler. It demonstrates how to correctly specify input data, initial parameters, adaptation settings, output file, and random number generator initialization within a single command. ```Shell ./my_model sample num_warmup=2000 \ init=my_param_inits.json \ adapt delta=0.95 init_buffer=100 \ window=50 term_buffer=100 \ algorithm=hmc engine=nuts max_depth=15 \ metric=dense_e metric_file=my_metric.json \ stepsize=0.6555 \ data file=my_model.data.json \ output file=output_${i}.csv refresh=10 \ random seed=12345 id=${i} ``` -------------------------------- ### Verify C++ Compiler and Make on Windows Source: https://github.com/stan-dev/docs/blob/master/docs/2_29/cmdstan-guide/cmdstan-installation.html This snippet provides shell commands to check the installed versions of `g++` and `mingw32-make` on a Windows system, confirming the successful setup of the C++ development environment. ```Shell g++ --version mingw32-make --version ``` -------------------------------- ### Compiling a Stan Program into an Executable with Make Source: https://github.com/stan-dev/docs/blob/master/docs/2_31/cmdstan-guide/cmdstan-installation.html To build a Stan program (e.g., `foo/bar.stan`) into an executable, use `make foo/bar`. This process automatically installs the Stan compiler, generates C++ code, and then compiles it to create the final executable. ```Shell make foo/bar ``` -------------------------------- ### Build CmdStan from Source Source: https://github.com/stan-dev/docs/blob/master/docs/2_26/cmdstan-guide/cmdstan-installation.html Instructions to compile CmdStan utilities and necessary C++ libraries using the makefile 'build' target. Includes specific command for Windows users. ```Shell cd make build # on Windows use mingw32-make ``` -------------------------------- ### Verify C++ Compiler and Make on MacOS Source: https://github.com/stan-dev/docs/blob/master/docs/2_29/cmdstan-guide/cmdstan-installation.html This snippet provides shell commands to check the installed versions of `clang++` and `make` on a MacOS system, confirming the successful setup of the C++ development environment. ```Shell clang++ --version make --version ``` -------------------------------- ### Example of Incorrect Make Invocation Error Source: https://github.com/stan-dev/docs/blob/master/docs/2_30/cmdstan-guide/cmdstan-installation.html This snippet demonstrates the error messages encountered when attempting to invoke the CmdStan Makefile from a directory other than ``, highlighting the importance of running `make` from the correct location. ```Bash make -f ~/github/stan-dev/cmdstan/makefile /Users/mitzi/github/stan-dev/cmdstan/makefile:58: make/stanc: No such file or directory /Users/mitzi/github/stan-dev/cmdstan/makefile:59: make/program: No such file or directory /Users/mitzi/github/stan-dev/cmdstan/makefile:60: make/tests: No such file or directory /Users/mitzi/github/stan-dev/cmdstan/makefile:61: make/command: No such file or directory make: *** No rule to make target `make/command'. Stop. ```