3.8 Qualitative Predictors
- Dummy variables: if there are k levels, introduce k−1 dummy variables which are equal to one (“one hot”) when the underlying qualitative predictor takes that value. For example if there are 3 levels, introduce two new dummy variables and fit the model:
yi=β0+β1xi1+β2xi2+ϵi
Qualitative Predicitor | xi1 | xi2 |
---|---|---|
level 0 (baseline) | 0 | 0 |
level 1 | 1 | 0 |
level 2 | 0 | 1 |
Coefficients are interpreted the average effect relative to the baseline.
Alternative is to use index variables, a different coefficient for each level:
yi=β01+β02+β03+ϵi