Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suprising gRsqr calculation in neutral.fit #30

Open
bhagavadgitadu22 opened this issue Jan 26, 2024 · 1 comment
Open

Suprising gRsqr calculation in neutral.fit #30

bhagavadgitadu22 opened this issue Jan 26, 2024 · 1 comment

Comments

@bhagavadgitadu22
Copy link

Hello,

I am using the neutral.fit function and I was surprised by the gRsqr results I was getting: they were not sustaining the visual impression I had of the fit. I tried to calculate the generalized R squared using the formula provided in Burns et al. (2015, ISME J 10(3):655-664) and I got very different results that fitted what I expected.

In Burns and al., they calculate R2 with: R2 = 1 - SSerr/SStotal
with SSerr the sum of squares of residuals and SStotal the total sum of squares

In neutral.fit, gRsqr is calculated with: R2 = 1 - exp(-as.numeric(logLik(m.mle))/length(p))
with p the number of observations and logLik(m.mle) the log likelihood of the model predicted by mle2

Do you have an insight on the difference between the two calculations?

Thanks,

@Russel88
Copy link
Owner

R2 = 1 - SSerr/SStotal is the standard way to calculate R2, but that assumes homoscedasticity. Here the response is bounded between 0 and 1 and the residuals will always be heteroscedastic. What I have implemented is a Pseudo-R2, but it might not be correct in all situations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants