source("http://192.38.117.59/~linearpredictors/datafiles/readSurgery.R") ## remove surgery type "orthopedic" surgery2 <- subset(surgery, surgtype %in% 2:3) surgery2$surgtype <- surgery2$surgtype[drop = TRUE] logistic <- glm(complication ~ surgtype - 1, family = binomial, data = surgery2) ## n_j and S_j t <- table(surgery2$surgtype, surgery2$complication) addmargins(t) ## estimates on probability scale with corresponding standard deviations est <- predict(logistic, ## predicting the probability for both surgery types data.frame(surgtype = factor(2:3)), type = "response", se.fit = T) ## lower confidence limits (normal approximation) est$fit - 1.96 * est$se.fit ## upper confidence limits est$fit + 1.96 * est$se.fit