Solved – Combining categorical and continuous variables to calculate a factor

categorical dataconfirmatory-factorcontinuous data

I have a categorical predictor (income) and three continuous predictors (area, no. of bed rooms and no of cars). How can I form a single factor from these variables? In other words I want to combine all these variables to get one single variable.

Best Answer

If all of them are integer values less than 10, you could use

fac = 100*income + 10*bdrms + cars

Then you'll get 3-digit codes, each digit being the level of the corresponding variable.

Oops, I'm realizing I excluded area. Is that an integer code too? If so, use the same idea with 4 digits. Otherwise, could use

area + fac/1000

and you'll have the 3-digit code after the decimal point and the area before.