This book provides a highly practical introduction to Bayesian statistical modeling with Stan, which has become the most popular probabilistic programming language. The book is divided into four parts. The first part reviews the theoretical background of modeling and Bayesian inference and presents a modeling workflow that makes modeling more engineering than art. The second part discusses the use of Stan, CmdStanR, and CmdStanPy from the very beginning to basic regression analyses. The third part then introduces a number of probability distributions, nonlinear models, and hierarchical (multilevel) models, which are essential to mastering statistical modeling. It also describes a wide range of frequently used modeling techniques, such as censoring, outliers, missing data, speed-up, and parameter constraints, and discusses how to lead convergence of MCMC. Lastly, the fourth part examines advanced topics for real-world data: longitudinal data analysis, state space models, spatial data analysis, Gaussian processes, Bayesian optimization, dimensionality reduction, model selection, and information criteria, demonstrating that Stan can solve any one of these problems in as little as 30 lines. Using numerous easy-to-understand examples, the book explains key concepts, which continue to be useful when using future versions of Stan and when using other statistical modeling tools.
The examples do not require domain knowledge and can be generalized to many fields. The book presents full explanations of code and math formulas, enabling readers to extend models for their own problems. All the code and data are on GitHub.