Created
May 31, 2013 23:25
-
-
Save Guibrich/5688620 to your computer and use it in GitHub Desktop.
This file contains 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
# We compute the inverse logistic function | |
ilogit <- function (l) { | |
exp(l) / ( 1 + exp(l) ) | |
} | |
attach(don) | |
viaglm<- glm(GROUPE~TAILLE,don,family="binomial") | |
png("Comparison.png", width=1280,height=800) | |
plot(TAILLE,GROUPE, pch=16) | |
new<- seq(min(TAILLE),max(TAILLE),by=1) | |
# Prev avec R | |
prevviaglm <- predict(viaglm,data.frame(TAILLE=new),type='response') | |
lines(new,prevviaglm, col="salmon1", lwd=6, lty=2) | |
# Prev à la amin | |
lines(new, ilogit(Test$coef.est[1]+new*Test$coef.est[2]), col = "navyblue", lwd=2) | |
legend( .95*par('usr')[1]+.05*par('usr')[2], .9, | |
c("Avec predict glm", | |
"A la main"), | |
col=c("salmon1","navyblue"),lty=c(2,1), lwd=c(6,2)) | |
title(main="Rég log. à la main + avec glm()") | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment