2 added 61 characters in body
source | link

Mechanically, you can do either encodings, but be aware that if you do the former (i.e. dummies variables for red, green, and blue), then you cannot include a constant term in your regression because it will make your data matrix $X$ rank deficient!

On the other hand:

red = (1,0)
green = (0,1)
blue = (0,0)

will give the coefficients for red and green a natural interpretation as the log of the odds ratio relative to blue.

Another note is that your first encoding without a dummy is fundamentally the same regression as your second encoding with a dummy in the sense that a little linear algebra and math can figure out the results for one regression given the results of the other.

Detailed example about rank deficient data matrix:

Imagine you have 2 observations that are red, 2 observations that are green, and 2 that are blue. Every observation is either red, green, or blue. Your data matrix could be something like:

$$X = \begin{bmatrix} 1 & 1 & 0 & 0 \\ 1 & 0 & 1 & 0 \\ 1 & 0 & 1 & 0 \\ 1 & 0 & 0 & 1 \\ 1 & 1 & 0 & 0 \\ 1 & 0 & 0 & 1 \end{bmatrix}$$

The first column denotes a constant, the 2nd colum is an indicator for red, the 3rd column an indicator for green, and the 4th an indicator for blue. The matrix is rank deficint because the first column equals the sum of the other 3 columns! Full column rank would be 4, but this matrix is only rank 3.

Mechanically, you can do either encodings, but be aware that if you do the former (i.e. dummies variables for red, green, and blue), then you cannot include a constant term in your regression because it will make your data matrix $X$ rank deficient!

On the other hand:

red = (1,0)
green = (0,1)
blue = (0,0)

will give the coefficients for red and green a natural interpretation as the log of the odds ratio relative to blue.

Another note is that your first encoding without a dummy is fundamentally the same regression as your second encoding with a dummy in the sense that a little linear algebra and math can figure out the results for one regression given the results of the other.

Detailed example about rank deficient data matrix:

Imagine you have 2 observations that are red, 2 observations that are green, and 2 that are blue. Every observation is either red, green, or blue. Your data matrix could be something like:

$$X = \begin{bmatrix} 1 & 1 & 0 & 0 \\ 1 & 0 & 1 & 0 \\ 1 & 0 & 1 & 0 \\ 1 & 0 & 0 & 1 \\ 1 & 1 & 0 & 0 \\ 1 & 0 & 0 & 1 \end{bmatrix}$$

The first column denotes a constant, the 2nd colum is an indicator for red, the 3rd column an indicator for green, and the 4th an indicator for blue. The matrix is rank deficint because the first column equals the sum of the other 3 columns!

Mechanically, you can do either encodings, but be aware that if you do the former (i.e. dummies variables for red, green, and blue), then you cannot include a constant term in your regression because it will make your data matrix $X$ rank deficient!

On the other hand:

red = (1,0)
green = (0,1)
blue = (0,0)

will give the coefficients for red and green a natural interpretation as the log of the odds ratio relative to blue.

Another note is that your first encoding without a dummy is fundamentally the same regression as your second encoding with a dummy in the sense that a little linear algebra and math can figure out the results for one regression given the results of the other.

Detailed example about rank deficient data matrix:

Imagine you have 2 observations that are red, 2 observations that are green, and 2 that are blue. Every observation is either red, green, or blue. Your data matrix could be something like:

$$X = \begin{bmatrix} 1 & 1 & 0 & 0 \\ 1 & 0 & 1 & 0 \\ 1 & 0 & 1 & 0 \\ 1 & 0 & 0 & 1 \\ 1 & 1 & 0 & 0 \\ 1 & 0 & 0 & 1 \end{bmatrix}$$

The first column denotes a constant, the 2nd colum is an indicator for red, the 3rd column an indicator for green, and the 4th an indicator for blue. The matrix is rank deficint because the first column equals the sum of the other 3 columns! Full column rank would be 4, but this matrix is only rank 3.

1
source | link

Mechanically, you can do either encodings, but be aware that if you do the former (i.e. dummies variables for red, green, and blue), then you cannot include a constant term in your regression because it will make your data matrix $X$ rank deficient!

On the other hand:

red = (1,0)
green = (0,1)
blue = (0,0)

will give the coefficients for red and green a natural interpretation as the log of the odds ratio relative to blue.

Another note is that your first encoding without a dummy is fundamentally the same regression as your second encoding with a dummy in the sense that a little linear algebra and math can figure out the results for one regression given the results of the other.

Detailed example about rank deficient data matrix:

Imagine you have 2 observations that are red, 2 observations that are green, and 2 that are blue. Every observation is either red, green, or blue. Your data matrix could be something like:

$$X = \begin{bmatrix} 1 & 1 & 0 & 0 \\ 1 & 0 & 1 & 0 \\ 1 & 0 & 1 & 0 \\ 1 & 0 & 0 & 1 \\ 1 & 1 & 0 & 0 \\ 1 & 0 & 0 & 1 \end{bmatrix}$$

The first column denotes a constant, the 2nd colum is an indicator for red, the 3rd column an indicator for green, and the 4th an indicator for blue. The matrix is rank deficint because the first column equals the sum of the other 3 columns!