Stepwise regression

Is there any way to force keep dummy coded variable in the step wise regression model if any one of the level is significant? I cannot share my actual dataset but I will try to be clear. Suppose I have a categorical variable Y2 with 4 levels and there are three dummy coded variables, while doing stepwise regression I want to include them as group if one those is significant.

model_trn <- lm(X ~ ., 
                data = train[, c(y, y1, y2.1, y2.2, y2.3, y3) 

# backward stepwise
sw_trn <- ols_step_backward_p(model_trn,details=TRUE, pent = 0.2, prem = 0.2)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.