pseudo R2 calculation with mnrfit/mnrval

20 views (last 30 days)
Richard Ott
Richard Ott on 21 Feb 2019
Edited: Jae Hyung Woo on 10 Oct 2022
Hi,
I'm doing a nominal logistic regression with mnrfit.
However, there is no in-built way of calculating different common pseudo-R² (pR2) for the regression.
I'd like to calculate some common pR2's for my regression and I know that dev = 2*ln(likelihood of my model).
E.g. McFadden's pR2 is 1- ln(full model)/ln(intercept model). Therefore, if I had the dev of the intercept model I could calculate McFaddens pR2
with 1-dev(full model)/dev(intercept model). But how do I calculate the intercept model?
Thanks,
Richard

Answers (1)

Jae Hyung Woo
Jae Hyung Woo on 10 Oct 2022
Edited: Jae Hyung Woo on 10 Oct 2022
I was also looking for the solution to this question and here is what I figured out:
If you want to compute the pseudo R^2 from scratch, you can obtain likelihood of the intercept model using the intercept of your initial fit, i.e., the first cofficient in B = mnrfit(X,Y).
Here, the 'intercept' is B(1). Use this value to run another logistic regression with the null model, by
[B_null, dev_null] = mnrfit(B(1)*ones(size(X)), Y)
Then dev_null = 2*ln(intercpet model), which is what you want. This will give R^2 = 1 - dev(full_model)/dev_null.
However, it turns out that there is a function that has built-in output for Pseduo-R^2 (Thanks to Kelly in this thread): use 'fitglm' function to run logistic regression (specify 'Distribution' as 'binomial'), and the output structure contains the McFadden pseudo R-squared as Rsquared.LLR.

Community Treasure Hunt

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

Start Hunting!