# Choosing between alternate pseudo R squared methods [duplicate]

My project uses logistic regression and I needed to calculate pseudo r squared to understand the explanatory power of each model.

I have been using the formula below to calculate what I thought was equivalent to pseudo R squared by comparing a null model using just the intercept to the full specified model to be measured.

mod1 <- glm(yn~hinctnta+hincfel+uemp5yr+stfeco+gincdif, data=euro,family = "binomial")
summary(mod1)

nullmod1 <- glm(yn~1, data=euro, family="binomial")
1-logLik(mod1)/logLik(nullmod1)


I noticed that some of the results were higher than expected. Therefore I sought out additional ways to calculate R2 and used the following function which calculates Hosmer and Lemeshows R squared as well as Nagelkerke and Cox and Snell. Testing 5 different models showed very different (lower) results than those showed by my first attempt using the simple null model.

My question therefore is what is the theoretical difference between the two approaches and is there any validity in just using the first simpler approach to report pseudo r squared?

Function to calculate R squared:

logisticPseudoR2s <- function(LogModel) {
dev <- LogModel$deviance nullDev <- LogModel$null.deviance
modelN <- length(LogModel\$fitted.values)
R.l <- 1 - dev / nullDev
R.cs <- 1 - exp ( -(nullDev - dev)/ modelN)
R.n <- R.cs / ( 1 - (exp (-(nullDev / modelN))))
cat("Pseudo R^2 for logistic regression\n")
cat("Hosmer and lemeshow R^2", round(R.l, 3), "\n")
cat("Cox and Snell R^2", round(R.cs, 3), "\n")
cat("Nagelkerke R^2", round(R.n, 3), "\n")
}

logisticPseudoR2s(mod)


## marked as duplicate by kjetil b halvorsen, Michael Chernick, Peter Flom♦Apr 6 at 11:03

You know that there are some already implemented functions for pseudo-R2 in R? I used PseudoR2 from the package BaylorEdPsych in the past. That way you could check if your pseudo R2 calculation is correct.
• good to know about that package, I like that it reports as many as 6 different Pseudo R2s. I'm wondering if anybody can unpack for me what the formula 1-logLik(mod1)/logLik(nullmod1) does and whether this can be seen as a form of R2 itself? – Henry Cann May 7 '17 at 12:24