source("http://192.38.117.59/~linearpredictors/datafiles/readSurgery.R") surgery$age60 <- (surgery$age-60)/10 surgery$dur60 <- surgery$duration/60-1 surgery$tof07 <- (surgery$tofratio-0.7)*10 model <- glm(complication ~ surgtype + age60 + dur60 + longact + longact:tof07, family = binomial, data = surgery) ## the rows in surgery used in the fit used.data <- surgery[rownames(model$model),] par(mfrow = c(2,2)) ## cooks distance plot(cooks.distance(model) ~ age, data = used.data, xlab = "Age", ylab = "Cook's distance", pch = ifelse(used.data$complication == 1, 4, 21) ## cross = complication, o = no complication. ) ## influential measures for all coefficients. ## The R-function "dfbetas" gives similar quantities dfb <- function(){ se <- sqrt(diag(summary(model)$cov.unscaled)) refit <- function(i){ ## fit without observation i model.i <- update(model, data = used.data[-i,]) (model$coef - model.i$coef)/se } t(sapply(1:nrow(used.data), refit)) } dfbetas <- dfb() plot(subset(dfbetas, select = age60) ~ age, data = used.data, xlab = "Age", ylab = "Influence, age", pch = ifelse(used.data$complication == 1, 4, 21) ) plot(subset(dfbetas, select = dur60) ~ duration, data = used.data, xlab = "Duration of anesthesia", ylab = "Influence, duration", pch = ifelse(used.data$complication == 1, 4, 21) ) plot(subset(dfbetas, select = which(names(model$coef) == "longact1:tof07")) ~ tofratio, data = used.data, xlab = "TOF-ratio", ylab = "Influence, TOF-ratio and long-act interaction", pch = ifelse(used.data$complication == 1, 4, 21) )