# Categorical variable in regression

I am building a linear regression model and have a few categorical predictors. I have created (#levels - 1)dummy/indicator variables for each of the categorical covariates. Lets say the variable is temp = ( hot, moderate, cold ). I have created 2 dummy variables for hot and cold.

My doubt is in the model, can i have just have one of the indicator variables in the model or is it a all or none way of including categorical variables.

I have used backward elimination method and in the final model i am getting just dummy variable corresponding to hot. Can i use this model or should i ensure that either both the dummy variables are present or none.

Appreciate the help.

It's perfectly reasonable to include only some levels of a categorical predictor in a regression model. We can make this clear with a simple example. Suppose you have some response variable $Y_i$ whose mean level depends only on whether a subject is male or female and we decide to define a categorical variable that takes on the values

$$\{ \text{male}, \text{female with brown hair}, \text{female without brown hair} \} .$$

We then dummy code this variable and fit the model

$$\text{E}(Y_i) = \alpha + \beta_1 x_{i1} + \beta_2 x_{i2}$$

where $x_{i1}$ indicates if the subject is male and $x_{i2}$ indicates if the subject is female with brown hair. Under this model $\alpha$ represents the effect of being a female without brown hair, but if we drop $x_{i2}$ then it represents the effect of being female and we've identified the true model.

Basically you should let the data determine which categories are important and not decide a priori that the way in which a categorical variable is defined is the most meaningful for purposes of prediction.

Everybody is free to use any model they want of course, the question is - will that model be useful or not. If backward elimination process excluded dummy variable for temp=cold then all it means is just that your model 'needs' only two levels of temp to operate:

• moderate or cold, when dummy variable for hot=0
• hot, when dummy variable for hot=1

So your model does not distinguishes between temp being moderate or cold, the only thing that matters is whether temp is hot.

I suppose that if categorial variable in question was made from quantitative by domain splitting then you might look into choosing another splitting policy, for example made it to temp be one of {very hot, moderate hot, ModerateOrCold}

• So instead of 2, if i have 5 levels. In the model i have included the 4 dummy variables representing the 5 levels. If 2/4 is significant in terms of p-value, should i retain those 2 levels in the model and assume the other levels are not important?
– Raj
Mar 11, 2016 at 2:55
• Yes, I think you might. It's your call anyway. Mar 11, 2016 at 6:15