The following case studies intend to introduce users to Multilevel regression and poststratification (MRP), providing reusable code and clear explanations. The first chapter presents MRP, a statistical technique that allows to estimate subnational estimates from national surveys while adjusting for nonrepresentativeness. The second chapter extends MRP to overcome the limitation of only using variables included in the census. Lastly, the third chapter provides an example on how to download and preprocess survey and census data in the US context.

We assume certain familiarity with R and Bayesian statistics. A good reference for the required background is Gelman, Hill, and Vehtari (2020), with Chapter 17 on poststratification being particularly relevant. Additionally, multilevel models are covered in Gelman and Hill (2006) (Part 2A) or McElreath (2020) (Chapters 12 and 13).

These tutorials do not display some non-essential code, such as the ones used to generate figures and tables. However, all the code is available on GitHub as Rmarkdown files (01-mrp-intro.Rmd, 02-mrp-noncensus.Rmd, and 03-data-processing.Rmd).

The case studies are still under development. Please send any feedback to


Gelman, Andrew, and Jennifer Hill. 2006. Data Analysis Using Regression and Multilevel/Hierarchical Models. Cambridge University Press New York, NY, USA.

Gelman, Andrew, Jennifer Hill, and Aki Vehtari. 2020. Regression and Other Stories. Cambridge University Press.

McElreath, Richard. 2020. Statistical Rethinking: A Bayesian Course with Examples in R and Stan. CRC press.

  1. The authors would like to thank Lauren Kennedy and Jonah Gabry, who developed an initial version the MRP introduction, and Mitzi Morris, for her extensive feedback and helpful discussions.