Skip to content

Instantly share code, notes, and snippets.

@Guibrich
Created May 31, 2013 23:25
Show Gist options
  • Save Guibrich/5688620 to your computer and use it in GitHub Desktop.
Save Guibrich/5688620 to your computer and use it in GitHub Desktop.
# 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