I need to create possible combinations of 3 dummy variables into one categorical variable in a logistic regression using R. I made the combination manually just like the following:

new_variable_code variable_1 variable_2 variable_3

1 0 0 0

2 0 1 0

3 0 1 1

4 1 0 0

5 1 1 0

6 1 1 1

I excluded the other two options (0 0 1) and (1 0 1) because I do not need them, they are not represented by the data. I then used new_variable_code as a factor in the logistic regression along with other predictors.

My question is: Is there is any automated way to create the same new_variable_code? or even another econometric technique to encode the 3 dummy variables into 1 categorical variable inside a logistic regression model?

My objective: To understand which variable combination has the highest odds ratio on the outcome variable (along with other predictors explained in the same model).

Thank you

More Zeinab Elrashidy's questions See All
Similar questions and discussions