7 Linear and logistic regression

This chapter covers

  • Using linear regression to predict quantities
  • Using logistic regression to predict probabilities or categories
  • Extracting relations and advice from linear models
  • Interpreting the diagnostics from R’s lm() call
  • Interpreting the diagnostics from R’s glm() call
  • Using regularization via the glmnet package to address issues that can arise with linear models.

In the previous chapter, you learned how to evaluate models. Now that we have the ability to discuss if a model is good or bad, we’ll move on to the modeling step, as shown in the mental model (figure 7.1). In this chapter, we’ll cover fitting and interpreting linear models in R.

Figure 7.1. Mental model

Linear models are especially useful ...

Get Practical Data Science with R, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.