In fitglm, how can I have a predictor as both categorical and ordinal?
조회 수: 15 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (2개)
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
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ß
2018년 6월 7일
Ordinal variables in Matlab can be handeled by mnrfit.
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
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!