LinearModel with categorical variables - how do I establish which coefficients are derived from what input variables?
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!