Tidy Modeling with R
Version 0.0.1.9008 (2021-02-23)
This is the website for Tidy Modeling with R. This book is a guide to using a new collection of software in the R programming language for model building, and it has two main goals:
First and foremost, this book provides an introduction to how to use our software to create models. We focus on a dialect of R called the tidyverse that is designed to be a better interface for common tasks using R. If you’ve never heard of or used the tidyverse, Chapter 2 provides an introduction. In this book, we demonstrate how the tidyverse can be used to produce high quality models. The tools used to do this are referred to as the tidymodels packages.
Second, we use the tidymodels packages to encourage good methodology and statistical practice. Many models, especially complex predictive or machine learning models, can work very well on the data at hand but may fail when exposed to new data. Often, this issue is due to poor choices made during the development and/or selection of the models. Whenever possible, our software, documentation, and other materials attempt to prevent these and other pitfalls.
This book is not intended to be a comprehensive reference on modeling techniques; we suggest other resources to learn such nuances. For general background on the most common type of model, the linear model, we suggest Fox (2008). For predictive models, Kuhn and Johnson (2013) is a good resource. Also, Kuhn and Johnson (2020) is referenced heavily here, mostly because it is freely available online. For machine learning methods, Goodfellow, Bengio, and Courville (2016) is an excellent (but formal) source of information. In some cases, we describe models that are used in this text but in a way that is less mathematical, and hopefully more intuitive.
Investigating and analyzing data are an important part of the model process, and an excellent resource on this topic is Wickham and Grolemund (2016).
We do not assume that readers have extensive experience in model building and statistics. Some statistical knowledge is required, such as random sampling, variance, correlation, basic linear regression, and other topics that are usually found in a basic undergraduate statistics or data analysis course.
Tidy Modeling with R is currently a work in progress. As we create it, this website is updated. Be aware that, until it is finalized, the content and/or structure of the book may change.
This openness also allows users to contribute if they wish. Most often, this comes in the form of correcting typos, grammar, and other aspects of our work that could use improvement. Instructions for making contributions can be found in the
contributing.md file. Also, be aware that this effort has a code of conduct, which can be found at
The tidymodels packages are fairly young in the software lifecycle. We will do our best to maintain backwards compatibility and, at the completion of this work, will archive and tag the specific versions of software that were used to produce it.
This book was written in RStudio using bookdown. The
tmwr.org website is hosted via Netlify, and automatically built after every push by GitHub Actions. The complete source is available on GitHub. We generated all plots in this book using ggplot2 and its black and white theme (
theme_bw()). This version of the book was built with R version 4.0.4 (2021-02-15), pandoc version 2.7.3, and the following packages:
|av||0.5.1||CRAN (R 4.0.2)|
|bookdown||0.21||CRAN (R 4.0.2)|
|broom||0.7.5||CRAN (R 4.0.4)|
|corrr||0.4.3||CRAN (R 4.0.2)|
|dials||0.0.9||CRAN (R 4.0.2)|
|digest||0.6.27||CRAN (R 4.0.2)|
|doMC||1.3.7||CRAN (R 4.0.2)|
|dplyr||1.0.4||CRAN (R 4.0.2)|
|ggforce||0.3.2||CRAN (R 4.0.2)|
|ggplot2||3.3.3||CRAN (R 4.0.2)|
|gridExtra||2.3||CRAN (R 4.0.2)|
|kableExtra||1.3.4||CRAN (R 4.0.4)|
|kernlab||0.9-29||CRAN (R 4.0.2)|
|kknn||1.3.1||CRAN (R 4.0.2)|
|knitr||1.31||CRAN (R 4.0.2)|
|lme4||1.1-26||CRAN (R 4.0.2)|
|lubridate||220.127.116.11||CRAN (R 4.0.2)|
|modeldata||0.1.0||CRAN (R 4.0.2)|
|nlme||3.1-152||CRAN (R 4.0.4)|
|nnet||7.3-15||CRAN (R 4.0.4)|
|parsnip||0.1.5||CRAN (R 4.0.2)|
|patchwork||1.1.1||CRAN (R 4.0.2)|
|purrr||0.3.4||CRAN (R 4.0.2)|
|ranger||0.12.1||CRAN (R 4.0.2)|
|recipes||0.1.15||CRAN (R 4.0.2)|
|rlang||0.4.10||CRAN (R 4.0.2)|
|rmarkdown||2.7||CRAN (R 4.0.4)|
|rpart||4.1-15||CRAN (R 4.0.4)|
|rsample||0.0.9||CRAN (R 4.0.2)|
|rstanarm||2.21.1||CRAN (R 4.0.2)|
|sessioninfo||1.1.1||CRAN (R 4.0.2)|
|themis||0.1.3||CRAN (R 4.0.2)|
|tibble||3.0.6||CRAN (R 4.0.2)|
|tidyposterior||0.0.3||CRAN (R 4.0.2)|
|tidyverse||1.3.0||CRAN (R 4.0.2)|
|workflows||0.2.1||CRAN (R 4.0.2)|
|yardstick||0.0.7||CRAN (R 4.0.2)|
Fox, J. 2008. Applied Regression Analysis and Generalized Linear Models. Second. Thousand Oaks, CA: Sage.
Goodfellow, I, Y Bengio, and A Courville. 2016. Deep Learning. MIT Press.
Kuhn, M, and K Johnson. 2013. Applied Predictive Modeling. Springer.
Kuhn, M, and K Johnson. 2020. Feature Engineering and Selection: A Practical Approach for Predictive Models. CRC Press.
Wickham, H, and G Grolemund. 2016. R for Data Science: Import, Tidy, Transform, Visualize, and Model Data. O’Reilly Media, Inc.