Clear Filters
Clear Filters

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

7 views (last 30 days)
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!

Answers (2)

the cyclist
the cyclist on 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.
TingTing on 24 Nov 2015
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 on 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.

Sign in to comment.

Karsten Reuß
Karsten Reuß on 7 Jun 2018
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 Comment
the cyclist
the cyclist on 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).

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!