How to write your first Stan program

How to write your first Stan program

🎙 Ben Lambert 👥 148K 📅 November 14, 2018 ⏱ 28 min 👁 38K 📄 tutorial 🧭 2026-08-17
Available in: English (current) Français

Keywords

StanBayesianRrstanMCMC

Summary

This tutorial by Ben Lambert explains how to write and run a Stan program using R and the rstan package. The video begins by outlining the process: generating fake data in R, writing a Stan model, compiling it, and running MCMC sampling. The model used is a simple normal likelihood for heights with priors on the mean and standard deviation. The author demonstrates how to write the Stan code, including the data, parameters, and model blocks, and highlights common syntax errors. After compiling the model, he shows how to pass data to Stan, run sampling with multiple chains, and check convergence diagnostics such as R-hat and effective sample size. He then extracts posterior samples and plots histograms. Finally, he introduces the ShinyStan package for interactive visualization of MCMC diagnostics. The video is practical and suitable for beginners, with clear explanations and visual demonstrations.

143 words

Critical Evaluation

Value of the Information & Strength of the Argument

The video provides valuable hands-on guidance for beginners in Bayesian modeling with Stan. The author clearly explains the structure of a Stan program and the reasoning behind each step, such as constraining parameters to avoid invalid values. The argumentation is solid, as he demonstrates the entire workflow from data generation to posterior analysis, and emphasizes the importance of convergence diagnostics. The tutorial is well-paced and easy to follow, making it a useful resource for those new to Stan.

Scientific Rigor, Source Quality, Title Accuracy

The scientific rigor is high for a tutorial: the author references his book and the Stan website for further information, and the code is correct. The title accurately reflects the content, which is a beginner’s guide to writing a first Stan program. The video does not cite specific academic sources, but it is based on established Bayesian methods. The tutorial is well-structured and provides practical advice, though it does not cover advanced topics or potential pitfalls in depth.

171 words

Title / Content Match

The title accurately reflects the content, which is a beginner-friendly guide to writing a first Stan program.

Quality & Reliability

8/10

The video is a clear, step-by-step tutorial on writing and running a Stan model in R. The author demonstrates practical implementation, explains the model structure, and provides diagnostic checks. The content is accurate and well-structured, though it does not delve into advanced topics or potential pitfalls.

Key Moments

Cited Sources

Concurring Sources

  • Stan website — The author recommends the Stan website for up-to-date information on installation and usage.

Contribution & Novelties

This video provides a clear, step-by-step introduction to writing and running a Stan program, which is valuable for beginners. It covers the essential blocks of a Stan model, the use of rstan in R, and basic convergence diagnostics. The tutorial is practical and directly applicable.

Pour aller plus loin :

  • Stan documentation — Official Stan user’s guide for deeper understanding.
  • Bayesian Data Analysis — The book by Gelman et al., referenced for advanced concepts.
  • RStan Getting Started — Official RStan wiki for installation and usage details.

86 words

Radar Profile

The radar profile shows high scores in information quantity, quality, and reliability, with a slightly lower technical level, reflecting the tutorial's beginner-friendly nature. The video is well-balanced and provides a solid foundation for learning Stan.

Reliability 8/10