[R] plot for binomial glm

Ben Bolker bolker at ufl.edu
Sun Oct 28 14:59:25 CET 2007




Radek John wrote:
> 
>  Hello everybody!
> I am trying to plot glm with family=binomial and can`t work it out. My
> Data
> are:
> 
> 


mort = data.frame(temp=c(32,32,32,37,37,37,42,42,42,47,47,47,52,52,52),
num = c( 7,8,8,15,15,17,11,28,15,10,12,13,18,19,22),
numdead = c(0,0,0,3,1,3,8,14,12,10,12,13,18,19,22))

glm.mort<-glm(cbind(numdead, num - numdead) ~ temp, family=binomial,
              data=mort)


with(mort,plot(numdead/num~temp))

## plot with larger points for repeated values
library(plotrix)
with(mort,sizeplot(temp,numdead/num,
                   xlab="temp",ylab="prop. dead"))
tempvec= seq(min(mort$temp),max(mort$temp),length.out=100)
pred = predict(glm.mort,"response",newdata=data.frame(temp=tempvec))
lines(tempvec,pred)


-- 
View this message in context: http://www.nabble.com/plot-for-binomial-glm-tf4706812.html#a13453632
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list