Created
August 12, 2015 02:04
-
-
Save hauselin/7444fdfaadaef9dfff52 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#function to compute R2s in logistic regression | |
logisticR2s <- function(logisticModel) { | |
modelDeviance <- logisticModel$deviance | |
nullDeviance <- logisticModel$null.deviance | |
n <- length(logisticModel$fitted.values) | |
R2HosmerLemeshow <- 1 - modelDeviance / nullDeviance | |
R2CoxSnell <- 1 - exp((modelDeviance - nullDeviance) / n) | |
R2Nagelkerke <- R2CoxSnell / (1 - exp( - (nullDeviance / n))) | |
col1 <- c("Hosmer and Lemeshow", "Cox and Snell", "Nagelkerke") | |
col2 <- c(R2HosmerLemeshow, R2CoxSnell, R2Nagelkerke) | |
col3 <- col2 * 100 | |
return(data.frame(RSquaredType = col1, | |
Value = round(col2, 2), | |
Percent = round(col3, 2))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment