# Read grouped beetle data from the web: data="http://www.stat.ufl.edu/~aa/glm/data/Beetles2.dat" beetle = read.table(data, header = T) # Inspect grouped beetle data: beetle # Fit logistic regression with logdose as covariate: fit=glm(cbind(dead,n-dead)~logdose,family=binomial,data=beetle) summary(fit) # Read ungrouped beetle data: data="http://www.stat.ufl.edu/~aa/glm/data/Beetles.dat" beetle.u = read.table(data, header = T) # Inspect ungrouped beetle data: head(beetle.u,n=10) tail(beetle.u,n=10) # Fit logistic regression model based on ungrouped data: fit.u=glm(y~x,family=binomial,data=beetle.u) #Info on how to use glm with different distributins/links: #('Details' gives useful info for binomial data) help("family") summary(fit.u) summary(fit) # The estimates, standard errors, z values (Wald statistics) and P-values are the # same for grouped and ungrouped data. But all outputs are not the same.