O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Imputing the missing values

We will now perform a simple mean imputation. However, rather than substituting with a single mean number, we will replace the NAs with the mean values based upon membership of these four groups:

  • Diabetes=pos/younger age range
  • Diabetes=neg/younger age range
  • Diabetes=neg/older age range
  • Diabetes=pos/older age range

We already have the Diabetes=neg/pos category, so how do we categorize into the younger/older age group?

We will do that by automatically calculating a cut point. To determine the cut point, we will use the cut function on the Age variable so separate it into two levels. Then we will use dplyr to compute mean values for the five variables, depending upon how the age group was cut.

  1. First, let's see ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required