Why R-squares are different between "fitglm" and "fitglme"? or how do "fitglme" and "fitglm" calculate R-squared?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
Aditya Patil
2020년 11월 17일
How different is it? Some small differences might be present due to floating point accuracy. Can you provide complete code to reproduce the issue?
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!