rlinear-regressionmodel-comparison

Exhaustive Model Selection using One or More Factor Variables in R


I am attempting to construct a Linear Model based on a large number of explanatory variables (including interaction terms between variables) two of which are factor variables. Using a factor variable in either regsubsets() or leaps() causes an error. Is there another function or package I can use that will incorporate factor variables when attempting exhaustive model selection?

Thank You

James


Solution

  • I've had the same issue when setting up the leaps() or regsubsets() using the x and y matrices.

    However, regsubsets(y~x1cont+factor(x2)..., data=data) works for me. No error. Perhaps that may work for you?