source("http://192.38.117.59/~linearpredictors/datafiles/readFever.R") ## logistic regression using alcohol intake as covariate logistic <- glm(death ~ alco, family = binomial, data = fever) summary(logistic) ## Wald test for the slope = 0 b <- logistic$coef["alco"] se.b <- summary(logistic)$coefficients["alco", "Std. Error"] (W.logistic <- (b/se.b)^2) ## the p-value 1 - pchisq(W.logistic, df = 1) ## logistic regression using a scored alcohol intake ## means of bilirubin within quintile groups of bilirubin means <- tapply(fever$alco, fever$alcogroup, mean) names(means) <- NULL fever$scoredalco <- means[as.numeric(fever$alcogroup)] scoredlogistic <- glm(death ~ scoredalco, family = binomial, data = fever) summary(scoredlogistic) ## Wald test for the slope = 0 b <- scoredlogistic$coef["scoredalco"] se.b <- summary(scoredlogistic)$coefficients["scoredalco", "Std. Error"] (W.scoredlogistic <- (b/se.b)^2) ## the p-value 1 - pchisq(W.scoredlogistic, df = 1)