Nagelkerke R2 with different packages gives different values

 Let try different packages to estimate Nagelkerke (1991) R^2.

Nagelkerke NJD (1991) A note on a general definition of the coefficient of determination. Biometrika 78:691-192

nagelkerke() function from package companion truncates the significance digits at 6.

NagelkerkeR2() from package fmsb reports a different value as compare to other functions in the first example. I don't know why. I have contacted the author of the package and he does not know also.

install.packages("https://hebergement.universite-paris-saclay.fr/marcgirondot/CRAN/HelpersMG.tar.gz", repos=NULL, type="source")
library(HelpersMG)
library(rcompanion)
library(fmsb)

res <- glm(cbind(ncases,ncontrols) ~ agegp+alcgp+tobgp, data=esoph, family=binomial())

NagelkerkeR2(res)$R2
# [1] 0.9759681

nagelkerke(res)$Pseudo.R.squared.for.model.vs.null["Nagelkerke (Cragg and Uhler)", "Pseudo.R.squared"]
# [1] 0.965045

NagelkerkeScaledR2(x=esoph$ncases, size = esoph$ncases+esoph$ncontrols, prediction = res$fitted.values)
# [1] 0.9650451

Let do another example; no problem with this one:

data(AndersonBias)
model = glm(Result ~ County + Sex + County:Sex,
            weight = Count,
            data = AndersonBias,
            family = binomial(link="logit"))

NagelkerkeR2(model)$R2
# [1] 0.7136521

nagelkerke(model)$Pseudo.R.squared.for.model.vs.null["Nagelkerke (Cragg and Uhler)", "Pseudo.R.squared"]
# [1] 0.713652

NagelkerkeScaledR2(x=ifelse(AndersonBias$Result=="Fail", AndersonBias$Count, 0), 
                   size = AndersonBias$Count, prediction = model$fitted.values)
# [1] 0.7136521

Commentaires