pdf("ex0802.pdf") # Read in data from ASCII formatted (Fixed With File) ex0802dat <- read.fwf("http://www.stat.ufl.edu/~winner/data/biostat/ex0802.dat", width=c(8,8,8,8,8,8), col.names=c("bldprs","srmchlst","log10bp","log10sc","numdead","numlive")) # Create a dataset (frame) from input data ex0802 <- data.frame(ex0802dat) # Attach the dataset for analysis attach(ex0802) ex0802 # Compute the total cases and proportion dying for each combination of BP and SC totcase <- numdead+numlive propdead <- numdead/totcase # Fit the logistic regression model with dependent variable = death # and independent variable = dose # glm means generalized linear model, we are using the binomial distribution, and logit link function # The proportion dying at each combination of BP and SC, and weight is the total # of cases ex0802.reg <- glm(propdead ~ log10sc + log10bp, family=binomial("logit"), weight=totcase) summary(ex0802.reg) anova(ex0802.reg, test="Chisq") dev.off()