One simple way to avoid the dummy variable trap is to drop one of the dummy variables for each categorical variable in the model. This is known as the baseline or reference level approach, where one of the levels of the categorical variable is chosen as the reference and compared with the other levels. For example, if you have a categorical variable with three levels, C, D, and E, you can create two dummy variables, such as D1 = 1 if C, and D2 = 1 if D, and drop the dummy variable for E. This means that E is the reference level, and the coefficients of D1 and D2 measure the difference in the outcome between C and E, and D and E, respectively.
Another way to avoid the dummy variable trap is to use different coding schemes for the dummy variables, such as effect coding, orthogonal coding, or contrast coding. These coding schemes assign different values to the dummy variables, such as -1, 0, or 1, instead of 0 or 1, to make them orthogonal or uncorrelated with each other and with the intercept term. For example, if you use effect coding for a categorical variable with three levels, C, D, and E, you can create two dummy variables, such as D1 = 1 if C, D1 = -1 if D, and D1 = 0 if E, and D2 = 1 if D, D2 = -1 if E, and D2 = 0 if C. This means that the intercept term measures the mean outcome of all three levels, and the coefficients of D1 and D2 measure the deviation of C and D from the mean, respectively.