# Why do we need to discard one dummy variable?

I have learned that, for creating a regression model, we have to take care of categorical variables by converting them into dummy variables. As an example, if, in our data set, there is a variable like location:

Location
----------
Californian
NY
Florida


We have to convert them like:

1  0  0
0  1  0
0  0  1


However, it was suggested that we have to discard one dummy variable, no matter how many dummy variables are there.

Why do we need to discard one dummy variable?

• Because the third dummy can be explained as the linear combination of the first two: FL = 1 - (CA + NY). – chainD Feb 18 '18 at 18:15
• @chainD but what is the explanation for more than three dummy variable ? – Mithun Sarker Shuvro Feb 18 '18 at 18:20
• Whatever the total, it will just be 1 less than the total number of categories that you have. Extending your example, say all 50 states were represented in the dataset. For a given individual, say you look at the first 49 dummies which happen to be all zeros, then you know that the last dummy is a 1 even without looking (assuming everyone in the dataset is from one of the 50 states). In other words, the information of the last dummy is already contained in the result of the first 49, so to speak. – chainD Feb 18 '18 at 18:29
• @chainD thank you – Mithun Sarker Shuvro Feb 19 '18 at 4:32
• if it is not spring, not summer and not autumn then it is winter! – Stev Feb 19 '18 at 17:08

Note that if you using pandas.get_dummies, there is a parameter i.e. drop_first so that whether to get k-1 dummies out of k categorical levels by removing the first level. Please note default = False, meaning that the reference is not dropped and k dummies created out of k categorical levels!