Regression with a non-binary predictor

Back in a previous section, I promised that the same dummy-coding method that we used to regress binary categorical variables could be adapted to handle categorical variables with more than two values. For an example of this, we are going to use the same WeightLoss dataset as we did in to illustrate ANOVA.

To review, the WeightLoss dataset contains pounds lost and self-esteem measurements for three weeks for three different groups: a control group, one group just on a diet, and one group that dieted and exercised. We will be trying to predict the amount of weight lost in week 2 by the group the participant was in.

Instead of just having one dummy-coded predictor, we now need two. Specifically:

Consequently, ...

Get R: Data Analysis and Visualization 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.