Suppose we have a dataset, where Y and X are categorical. Y can only take the value 0 or 1. There are two ways how to represent the data (where of course Color and Shape will be factorized i.e. blue = 1, red = 2, green = 3, triangle = 1, circle = 2):

  1. ID    Defect    Color    Shape
     1      0       blue    triangle
     2      1       red     circle
     3      1       green   circle

The second way of representing the data is the following (binary):

    ID    Defect    red     blue    green    triangle    circle 
    1       0        0        1       0         1           0
    2       1        1        0       0         0           1
    3       1        0        0       1         0           1

Just imagine that we have a bigger dataset with more variables and observations. Can you tell from your experience, whether the setting of the datasets above will have an impact on the result?

Will for example the random forest packages handle both types of datasets?


Any regression method will require recoding into something like your second block quote, although there are various possible representations.

Often, this recoding is done "under the hood" but it's there. E.g in SAS you would use the CLASS statement and it would code the variables like the second example. Similar things happen in R, SPSS etc. (although the way to do it is different and the default parameterization of categorical variables may vary).

  • $\begingroup$ So in other words, it doesn't matter? $\endgroup$ – Textime Apr 8 at 18:09
  • $\begingroup$ No. In other words, the first one is impossible. But the choice of parameterization can make a difference, for sure. There's dummy coding, effect coding, Helmert coding and some others. They have been discussed here. $\endgroup$ – Peter Flom Apr 8 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.