## ----opts, results='hide', echo=FALSE, warning=F, message=F-------------- options(useFancyQuotes=F) library(DAMisc) library(apsrtable) library(xtable) library(factorplot) library(lattice) library(effects) library(knitr) opts_chunk$set( fig.path='l1figs/', tidy=FALSE ) ## ----label=inccat-------------------------------------------------------- data(Duncan) Duncan$inc.cat <- cut(Duncan$income, 3) mod <- lm(prestige~ inc.cat * type + education, data=Duncan) ## ----label=summod-------------------------------------------------------- summary(mod) ## ----incF1, echo=T------------------------------------------------------- Anova(mod) ## ----label=eff2cata, echo=TRUE, fig.show='hide', fig.height=5, fig.width=8---- e1 <- effect("inc.cat*type", mod) pe1 <- plot(e1, as.table=T, layout=c(3,1),ci.style="bars", rotx=45, main="", colors=c("black", "black"), lty=0, symbols=list(pch=16)) pe1 ## ----label=cat2mat------------------------------------------------------- tab2 <- cat2Table(e1) noquote(tab2) ## ----slid, echo=T-------------------------------------------------------- library(car) data(SLID) mod <- lm(wages ~ age*sex, data=SLID) summary(mod) ## ----linhyp, echo=T------------------------------------------------------ intQualQuant(mod, c("age", "sex"), type="slopes", plot=F) ## ----ps1, echo=T, fig.show='hide'---------------------------------------- trellis.par.set( superpose.line=list(col=c("red", "blue")), superpose.polygon = list(col=c("red", "blue"))) intQualQuant(mod, c("age", "sex"), type="slopes", plot=TRUE, rug=TRUE, ci=TRUE) ## ----iq1, echo=T, fig.show='hide', fig.height=6, fig.width=6------------- trellis.par.set( superpose.line=list(col=c("red", "blue")), superpose.polygon = list(col=c("red", "blue"))) iq <- intQualQuant(mod, c("age", "sex"), type="facs", plot=TRUE) ## ----catcont, echo=T----------------------------------------------------- Prestige$income <- Prestige$income/1000 mod <- lm(prestige ~ income*type + education, data=Prestige) ## ----label=summod2, echo=T----------------------------------------------- summary(mod) ## ----label=anova, echo=T------------------------------------------------- Anova(mod) ## ----label=condinc, echo=TRUE-------------------------------------------- intQualQuant(mod, c("income", "type"), type="slopes", plot=F) ## ----condinc2, echo=T, fig.show='hide', fig.height=6, fig.width=6-------- cols <- c("blue", "green", "red") trellis.par.set( superpose.line = list(col=cols), superpose.polygon = list(col=cols)) intQualQuant(mod, c("income", "type"), type="slopes", plot=TRUE) ## ----label=condtype, echo=TRUE, fig.show='hide', fig.height=5, fig.width=8---- mod.out <- intQualQuant(mod, c("income", "type"), type="facs", n=25, plot=T) update(mod.out, layout=c(3,1)) ## ----iqtab, echo=T------------------------------------------------------- intQualQuant(mod, c("income", "type"), vals=c(1,6.8,25), plot=F, type="facs") ## ----2contex, echo=T----------------------------------------------------- mod <- lm(prestige ~ income*education + type, data=Prestige) summary(mod) ## ----2cont1, echo=T------------------------------------------------------ DAintfun2(mod, c("income", "education"), hist=T, scale.hist=.3, plot.type="pdf") ## ----alt2cont, echo=T, fig.show='hide', warning=F, message=F------------- DAintfun(mod, c("income","education"), theta=-45, phi=20) ## ----bgm, echo=T--------------------------------------------------------- BGMtest(mod, vars=c("income", "education"))