A dummy variable is a type of variable that we create in regression analysis so that we can represent a categorical variable as a numerical variable that takes on one of two values: zero or one.
For example, suppose we have the following dataset and we would like to use age and marital status to predict income:
To use marital status as a predictor variable in a regression model, we must convert it into a dummy variable.
Since it is currently a categorical variable that can take on three different values (“Single”, “Married”, or “Divorced”), we need to create k-1 = 3-1 = 2 dummy variables.
To create this dummy variable, we can let “Single” be our baseline value since it occurs most often. Here’s how we would convert marital status into dummy variables:
This tutorial provides a step-by-step example of how to create dummy variables for this exact dataset in Excel and then perform regression analysis using these dummy variables as predictors.
Step 1: Create the Data
First, let’s create the dataset in Excel:
Step 2: Create the Dummy Variables
Next, we can copy the values in columns A and B to columns E and F, then use the IF() function in Excel to define two new dummy variables: Married and Divorced.
Here is the formula we used in cell G2, which we copied down to the rest of the cells in column G:
=IF(C2 = "Married", 1, 0)
And here is the formula we used in cell H2, which we copied down to the rest of the cells in column H:
=IF(C2 = "Divorced", 1, 0)
Next, we can use these dummy variables in a regression model to predict income.
Step 3: Perform Linear Regression
To perform multiple linear regression, we need to click the Data tab along the top ribbon, then Data Analysis within the Analysis section:
If you don’t see this option available, you need to first load the Analysis Toolpak.
In the window that pops up, click Regression and then click OK.
Next, fill in the following information and then click OK.
This produces the following output:
From the output we can see that the fitted regression line is:
Income = 14,276.12 + 1,471.67*(age) + 2,479.75*(married) – 8,397.40*(divorced)
We can use this equation to find the estimated income for an individual based on their age and marital status. For example, an individual who is 35 years old and married is estimated to have an income of $68,264:
Income = 14,276.12 + 1,471.67*(35) + 2,479.75*(1) – 8,397.40*(0) = $68,264
Here is how to interpret the regression coefficients from the table:
- Intercept: The intercept represents the average income for a single individual who is zero years old. Since an individual can’t be zero years old, it doesn’t make sense to interpret the intercept by itself in this particular regression model.
- Age: Each one year increase in age is associated with an average increase of $1,471.67 in income. Since the p-value (.004) is less than .05, age is a statistically significant predictor of income.
- Married: A married individual, on average, earns $2,479.75 more than a single individual. Since the p-value (0.800) is not less than .05, this difference is not statistically significant.
- Divorced: A divorced individual, on average, earns $8,397.40 less than a single individual. Since the p-value (0.532) is not less than .05, this difference is not statistically significant.
Since both dummy variables were not statistically significant, we could drop marital status as a predictor from the model because it doesn’t appear to add any predictive value for income.
How to Perform Simple Linear Regression in Excel
How to Calculate Residual Sum of Squares in Excel
How to Perform Polynomial Regression in Excel
How to Create a Residual Plot in Excel