# Examples from John Fox's JSS paper

library(effects)    # for Arrests data
library(car)        # for Anova()
data(Arrests)
Arrests$year <- as.factor(Arrests$year)

Main effects model

arrests.mod <- glm(released ~ employed + citizen + checks
 + colour*year + colour*age,
 family=binomial, data=Arrests)

Anova(arrests.mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: released
##             LR Chisq Df Pr(>Chisq)    
## employed      72.673  1  < 2.2e-16 ***
## citizen       25.783  1  3.820e-07 ***
## checks       205.211  1  < 2.2e-16 ***
## colour        19.572  1  9.687e-06 ***
## year           6.087  5  0.2978477    
## age            0.459  1  0.4982736    
## colour:year   21.720  5  0.0005917 ***
## colour:age    13.886  1  0.0001942 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

plot all effects

arrests.effects <- allEffects(arrests.mod, xlevels=list(age=seq(15,45,5)))
plot(arrests.effects, ylab="Probability(released)")

Plot 3-way effect (not in model)

plot(effect("colour:year:age", arrests.mod, xlevels=list(age=15:45)),
  multiline=TRUE, ylab="Probability(released)", rug=FALSE)

colour x year interaction

plot(effect("colour:year", arrests.mod),
      multiline=TRUE, ylab="Probability(released)")

colour x age interaction

plot(effect("colour:age", arrests.mod),
      multiline=FALSE, ylab="Probability(released)")