In fitglm, how can I have a predictor as both categorical and ordinal?

15 ビュー (過去 30 日間)
TingTing
TingTing 2015 年 11 月 23 日
コメント済み: the cyclist 2018 年 6 月 12 日
I have a predictor variable of AgeGroup. It has value of 1,2, 3... 9. I want it to be categorical and ordinal. However, if I use 'CategoricalVars',[2] in the fitglm command, it might not be ordinal. If I don't use 'CategoricalVars',[2], it is simply numerical... Please help!

回答 (2 件)

the cyclist
the cyclist 2015 年 11 月 23 日
The short answer is no. fitglm does not handle ordinal variables.
Ordinal variables are tricky beasts for linear regressions, as either the independent or dependent variables. Just starting from the wikipedia page about ordinal regression (and references therein), you can get a sense of how complex it is.
  2 件のコメント
TingTing
TingTing 2015 年 11 月 24 日
Mine is not really linear, but poisson... but I agree, they are trickier... However, I just can not interpret the result when they are not ordinal...
the cyclist
the cyclist 2015 年 11 月 24 日
I guess my broad point is that if the MATLAB documentation does not explicitly mention ordinal, then it is presumably not taking advantage of that info.
In the case of ordinal variables, it's not usually wrong to use categorical. But you are throwing away information.
The possible choices of how to handle that is way beyond the scope of what I could write here.

サインインしてコメントする。


Karsten Reuß
Karsten Reuß 2018 年 6 月 7 日
Ordinal variables in Matlab can be handeled by mnrfit.
Here's the theoretrical part: Multinomial models for ordinal responses
In practise you run the following command:
[B,dev,stats] = mnrfit(X,Y,'model','ordinal')
For predictions of probabilities you then use mnrval.
Now, don't ask me why MathWorks didn't implement this in their newer command fitglm yet. fitglm is much newer than mnrfit or glmfit, it was released in 2013.
  1 件のコメント
the cyclist
the cyclist 2018 年 6 月 12 日
Unless I am misunderstanding, the documentation you cite is for ordinal response variables, not ordinal predictor variables (which is what TingTing is asking about).
I think fitglm might be able to handle the case of ordinal response variable with the correct choice of link function, but I've never tried (and am not certain it can).

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by