Controlling for categorical variables

I have 8 independent variables which may be nominal or ordinal, and I want to see how each of them affect a numeric dependent variable $$Y$$, so that the effect of $$X_{1}$$ is controlled by the rest of variables $$X_{2}$$ through $$X_{8}$$.

How can I do this?

1 Answer

You could create a dummy variable (https://en.wikipedia.org/wiki/Dummy_variable_(statistics) ) for each category.

For example, if you have variable $$X_1$$ that can attain three values, say, $$X_1 = 1$$ or $$X_1 = 2$$ or $$X_1=3$$. Then create 3 new dummy variables, $$d_1, d_2, d_3$$, such that $$d_i = \begin{cases} 1 & \text{if } \ X_1 = i \\ 0 & \text{otherwise} \end{cases}$$ and regress $$Y = \delta_1 d_1 + \delta_2 d_1 + \delta_3 d_1 + \epsilon,$$ in order to estimate $$\delta_i$$. These parameters are equal to average $$Y$$ in the group of observations with $$X_1 = i$$. If there are other regressors, then $$\delta_i$$ correspond to a conditional mean, conditional on the impact of the other variables on the right-hand side.