data(Cowles)
mod.cowles <- glm(volunteer ~ sex + neuroticism*extraversion,
data=Cowles, family=binomial)
eff.cowles <- all.effects(mod.cowles, xlevels=list(neuroticism=0:24,
extraversion=seq(0, 24, 6)))
eff.cowles
model: volunteer ~ sex + neuroticism * extraversion
sex effect
sex
female male
0.4409441 0.3811941
neuroticism*extraversion effect
extraversion
neuroticism 0 6 12 18 24
0 0.07801066 0.1871263 0.3851143 0.6301824 0.8225756
1 0.08636001 0.1963396 0.3870453 0.6200668 0.8083638
2 0.09551039 0.2058918 0.3889798 0.6098458 0.7932997
3 0.10551835 0.2157839 0.3909179 0.5995275 0.7773775
. . .
23 0.51953129 0.4747277 0.4303273 0.3870199 0.3454282
24 0.54709527 0.4895731 0.4323256 0.3768303 0.3243880
plot(eff.cowles, 'sex', ylab="Prob(Volunteer)")
Loading required package: lattice
Loading required package: grid
plot(eff.cowles, 'neuroticism:extraversion', ylab="Prob(Volunteer)")
plot(eff.cowles, 'neuroticism:extraversion', multiline=TRUE,
ylab="Prob(Volunteer)")
plot(effect('sex:neuroticism:extraversion',
glm(volunteer ~ sex*neuroticism*extraversion, data=Cowles, family=binomial),
xlevels=list(neuroticism=0:24, extraversion=seq(0, 24, 6))), multiline=TRUE)
logit <- function(p) log(p/(1-p))
prob <- function(logit) 1/(1 + exp(-logit))
eff.cowles.2 <- all.effects(mod.cowles, xlevels=list(neuroticism=0:24,
extraversion=seq(0, 24, 6)), transformation=I)
plot(eff.cowles.2, transform=list(inverse=prob))
plot(eff.cowles.2, transform=list(link=logit, inverse=prob, at=c(.1,.25,.5,.75,.9)))
data(Prestige)
mod.pres <- lm(prestige ~ log(income, 10) + poly(education, 3) + poly(women, 2),
data=Prestige)
eff.pres <- all.effects(mod.pres, default.levels=50)
plot(eff.pres)
Run the code above in your browser using DataLab