mod.cowles <- glm(volunteer ~ sex + neuroticism*extraversion,
data=Cowles, family=binomial)
eff.cowles <- allEffects(mod.cowles, xlevels=list(neuroticism=0:24,
extraversion=seq(0, 24, 6)), given.values=c(sexmale=0.5))
eff.cowles
# the following are equivalent:
eff.ne <- effect("neuroticism*extraversion", mod.cowles)
Eff.ne <- Effect(c("neuroticism", "extraversion"), mod.cowles)
all.equal(eff.ne$fit, Eff.ne$fit)
plot(eff.cowles, 'sex', ylab="Prob(Volunteer)")
plot(eff.cowles, 'neuroticism:extraversion', ylab="Prob(Volunteer)",
ticks=list(at=c(.1,.25,.5,.75,.9)))
plot(eff.cowles, 'neuroticism:extraversion', multiline=TRUE,
ylab="Prob(Volunteer)")
plot(effect('sex:neuroticism:extraversion', mod.cowles,
xlevels=list(neuroticism=0:24, extraversion=seq(0, 24, 6))), multiline=TRUE)
# a nested model:
mod <- lm(log(prestige) ~ income:type + education, data=Prestige)
# does not work: effect("income:type", mod, transformation=list(link=log, inverse=exp))
plot(Effect(c("income", "type"), mod, transformation=list(link=log, inverse=exp),
ylab="prestige")) # works
mod.beps <- multinom(vote ~ age + gender + economic.cond.national +
economic.cond.household + Blair + Hague + Kennedy +
Europe*political.knowledge, data=BEPS)
plot(effect("Europe*political.knowledge", mod.beps,
xlevels=list(Europe=1:11, political.knowledge=0:3)))
plot(effect("Europe*political.knowledge", mod.beps,
xlevels=list(Europe=1:11, political.knowledge=0:3),
given.values=c(gendermale=0.5)),
style="stacked", colors=c("blue", "red", "orange"), rug=FALSE)
mod.wvs <- polr(poverty ~ gender + religion + degree + country*poly(age,3),
data=WVS)
plot(effect("country*poly(age, 3)", mod.wvs))
plot(effect("country*poly(age, 3)", mod.wvs), style="stacked")
plot(effect("country*poly(age, 3)", latent=TRUE, mod.wvs))
mod.pres <- lm(prestige ~ log(income, 10) + poly(education, 3) + poly(women, 2),
data=Prestige)
eff.pres <- allEffects(mod.pres, default.levels=50)
plot(eff.pres)
library(nlme) # for gls()
mod.hart <- gls(fconvict ~ mconvict + tfr + partic + degrees, data=Hartnagel,
correlation=corARMA(p=2, q=0), method="ML")
plot(allEffects(mod.hart))
library(lme4)
data(cake, package="lme4")
fm1 <- lmer(angle ~ recipe * temperature + (1|recipe:replicate), cake,
REML = FALSE)
plot(effect("recipe:temperature", fm1), grid=TRUE)
detach(package:lme4) # if previously attached
library(nlme)
data(cake, package="lme4")
cake$rep <- with(cake, paste( as.character(recipe), as.character(replicate), sep=""))
fm2 <- lme(angle ~ recipe * temperature, data=cake,
random = ~ 1 | rep, method="ML")
plot(effect("recipe:temperature", fm2), grid=TRUE)
Run the code above in your browser using DataLab