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

15 visualizaciones (últimos 30 días)
TingTing
TingTing el 23 de Nov. de 2015
Comentada: the cyclist el 12 de Jun. de 2018
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!

Respuestas (2)

the cyclist
the cyclist el 23 de Nov. de 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 comentarios
TingTing
TingTing el 24 de Nov. de 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 el 24 de Nov. de 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.

Iniciar sesión para comentar.


Karsten Reuß
Karsten Reuß el 7 de Jun. de 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 comentario
the cyclist
the cyclist el 12 de Jun. de 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).

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by