pseudo R2 calculation with mnrfit/mnrval

16 ビュー (過去 30 日間)
Richard Ott
Richard Ott 2019 年 2 月 21 日
編集済み: Jae Hyung Woo 2022 年 10 月 10 日
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

回答 (1 件)

Jae Hyung Woo
Jae Hyung Woo 2022 年 10 月 10 日
編集済み: Jae Hyung Woo 2022 年 10 月 10 日
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.

カテゴリ

Help Center および File ExchangeRegression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by