Data science simplified: Using qualitative variables in regression models
The last few articles of this series discussed regression models. Fernando, our data scientist who wanted to buy a car, has built a multivariate regression model with the following equation:
price = -55089.98 + 87.34 engineSize + 60.93 horse power + 770.42 width
The model predicts or estimates price (target) as a function of engine size, horsepower, and width (predictors). The model’s predictors are all numeric values. But what if there are qualitative variables? How can the qualitative variables be used in enhancing the models? How are the qualitative variables interpreted? These are the questions this article will answer.
Fernando has two such qualitative variables:
- fuelType: The type of fuel used. The value can be gas or diesel.
- driveWheels: The type of drive wheel. It has three values—four-wheel drive (4WD), rear-wheel drive (RWD), and front-wheel drive (FWD).
The data set looks like this:

Fernando wants to find out the impact these qualitative variables have on the price of the car.
Concept
Qualitative variables—also called categorical variables or factors—are variables that are not numerical and fits the data into categories.
Let us look at an example. The sample data has five cars and each one has a diesel or gas fuel type.

The fuel type is a qualitative variable. It has two levels (diesel or gas). The statistical package creates one dummy variable named fuelTypegas. The value of this variable is either 0 or 1. If the fuel type is gas, then the dummy variable is 1. If it’s diesel, then it’s 0.
Model building
Conclusion
Stay updated on the go with our mobile app.
Get latest insights with smoother, more personalized experience through TIA mobile app.






