What is the reference category for mnrfit when response variable is a categorical array

I'm using mnrfit to estimate a binary logit model. The document says
Y can be one of the following:
  • An n-by-k matrix, where Y(i,j) is the number of outcomes of the multinomial category j for the predictor combinations given by X(i,:). In this case, the number of observations are made at each predictor combination.
  • An n-by-1 column vector of scalar integers from 1 to k indicating the value of the response for each observation. In this case, all sample sizes are 1.
  • An n-by-1 categorical array indicating the nominal or ordinal value of the response for each observation. In this case, all sample sizes are 1.
and "The estimates for the kth category are taken to be zero as mnrfit takes the last category as the reference category". But if I have a categorical response variable (say H and L), how do I know which one MATLAB takes as the reference category without converting them to 1 and 2 first?

 채택된 답변

In general, the reference category will be the last category listed by "categories" function.
For example, in the first example in the "mnrfit" documentation, executing the following code:
>> cats=categories(sp)
results in:
cats =
'setosa'
'versicolor'
'virginica'
Here, the "mnrfit" function will use the last category in "cats" (in this case, "virginica") as the reference category.

댓글 수: 4

Thanks, this makes sense. By the way, in the first example in mnrfit documentation - is there a built-in command in MATLAB to back out the individual probabilities \pi_{species_j}, since the mnrfit gives prediction for log(ratio of 2 species) or do we just have to use fsolve to solve for these individually? Thanks!
hello, what if some of the prdictor variables are categorical?
I was wondering how you know this is correct. categories() seems to list categorical values alphabetically.
So, to make one variable my reference, I decided to choose a letter later in the alphabet. This didn't change the absolute value of the coefficients compared to the original model.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Saeed Babanajad
Saeed Babanajad 2021년 9월 18일
I am trying to use mnrfit to run a model on my data. My data has about five continours numeric variables and my output is an integer between 9 and 2. I have a couple very important questions that I will be so grateful if you could help:
1) should I use Hierarchical Multinomial Regression Model based on my output nature?
2) when I use the above type (and define my output using categorical function), how should I know that my B values (coefficient of the model) correspond to which output type? In other words, the B has a matrix of 8 columns. How can I know which columns correspond to which output category?
Your help is greatly appreciated!

카테고리

도움말 센터File Exchange에서 Variables에 대해 자세히 알아보기

질문:

2019년 2월 18일

댓글:

2023년 6월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by