Why R-squares are different between "fitglm" and "fitglme"? or how do "fitglme" and "fitglm" calculate R-squared?
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I am using "fitglme" for fitting a mixed-effect logistic regression model.
I could have R-squared from the fitted model.
glme.Rsqaured.Adjusted
Then, I tried to have individual-subject R-squared by using "fitglm" for each subject.
But, the subjectwise-averaged R-squared from "fitglm" was so different from the R-squared of "fitglme".
Why are they so different?
I found that the "fitglm"s R-squared can be derived by the definition of R-squred:
y = glm.Variable.y;
yhat = glm.predict;
ybar = mean(y);
SST = sum((y-ybar).^2);
SSR = sum((yhat-ybar).^2);
R_square = SSR/SST;
R_square_glm = glm.Rsquared.Ordinary;
R_square = R_square_glm;
However, "fitglme"s R-squred is different from the derived R-squared;
y = glme.Variable.y;
yhat = glme.predict;
ybar = mean(y);
SST = sum((y-ybar).^2);
SSR = sum((yhat-ybar).^2);
R_square = SSR/SST;
R_square_glm = glme.Rsquared.Ordinary;
R_square ~= R_square_glm;
How shoud I understand this inconsistency?
I will highly appreciate for you help!
4 Commenti
Aditya Patil
il 17 Nov 2020
How different is it? Some small differences might be present due to floating point accuracy. Can you provide complete code to reproduce the issue?
Risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!