In fitglm, how can I have a predictor as both categorical and ordinal?
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
the cyclist
am 23 Nov. 2015
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 Kommentare
the cyclist
am 24 Nov. 2015
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ß
am 7 Jun. 2018
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 Kommentar
the cyclist
am 12 Jun. 2018
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).
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!