Output from Arrests-effects.R

# Examples from John Fox's JSS paper

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

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.7  1    < 2e-16 ***
## citizen         25.8  1    3.8e-07 ***
## checks         205.2  1    < 2e-16 ***
## colour          19.6  1    9.7e-06 ***
## year             6.1  5    0.29785    
## age              0.5  1    0.49827    
## colour:year     21.7  5    0.00059 ***
## colour:age      13.9  1    0.00019 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# 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)")
# interactive call, allowing you to select plots from a menu
arrests.effects <- allEffects(arrests.mod, xlevels = list(age = seq(15, 45, 5)))
plot(arrests.effects, ylab = "Probability(released)")

Generated with R version 2.15.1 (2012-06-22) using the R package knitr (version 0.8.4) on Wed Sep 26 08:48:10 2012.