Clear Filters
Clear Filters

LinearModel with categorical variables - how do I establish which coefficients are derived from what input variables?

2 views (last 30 days)
If I do a linear regression using LinearModel.stepwise with one or several categorical predictor variables, the coefficients in the LinearModel are expressed in terms of the indicator variables. Is there an easy way of getting a matrix that shows which of the input variables each coefficient relates to? That is, basically a mapping between VariableNames and CoefficientNames.
When inspecting the LinearModel object you can see it from the names (input variable cat is converted to indicator variables cat_2, cat_3, cat_4 etc). You could work out the relationship by comparing names (lots of strcmp calls), but this seems an unnecessarily cumbersome way of doing something that must already happen within the fitting routine.
Cheers Kjeld

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!