# Writing a Metropolis-Hastings within Gibbs sampler in R for a 2PL IRT model (9 posts)

**Nathan VanHoudnos » rstats**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Last year, Brian Junker, Richard Patz, and I wrote an invited chapter for the (soon to be released) update of the classic text Handbook of Modern Item Response Theory (1996). The chapter is meant to be an update of the classic IRT in MCMC papers Patz & Junker (1999a, 1999b).

To support the chapter, I have put together an online supplement which gives a detailed walk-through of how to write a Metropolis-Hastings sampler for a simple psychometric model (in R, of course!). The table of contents is below:

- Post 1: A Bayesian 2PL model
- Post 2: Generating fake data
- Post 3: Setting up the sampler and visualizing its output
- Post 4: Sampling the person ability parameters
- Post 5: Refactoring Part I: a generic Metropolis-Hastings sampler
- Post 6: Refactoring Part II: a generic proposal function
- Post 7: Sampling the item parameters with generic functions
- Post 8: Sampling the variance of person ability with a Gibbs step
- Post 9: Tuning the complete sampler

I will continue to add to the online supplement over time. The next few posts will be:

- Post 10: Over dispersion and multi-core parallelism
- Post 11: Replacing R with C
- Post 12: Adaptive tuning of the Metropolis-Hastings proposals

I would be grateful for any feedback. Feel free to either leave it here or at the online supplement itself.

**leave a comment**for the author, please follow the link and comment on their blog:

**Nathan VanHoudnos » rstats**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.