# NOT RUN {
#### Basic workflow
lm0 <- lm(sr ~ pop15 + pop75, data = LifeCycleSavings)
lm1 <- lm(sr ~ dpi + ddpi, data = LifeCycleSavings)
lm2 <- lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings)
options(summary.stats.lm=c("R-squared","N"))
mtable("Model 1"=lm0,"Model 2"=lm1,"Model 3"=lm2)
options(summary.stats.lm=c("sigma","R-squared","N"))
mtable("Model 1"=lm0,"Model 2"=lm1,"Model 3"=lm2)
options(summary.stats.lm=NULL)
mtable123 <- mtable("Model 1"=lm0,"Model 2"=lm1,"Model 3"=lm2,
summary.stats=c("sigma","R-squared","F","p","N"))
(mtable123 <- relabel(mtable123,
"(Intercept)" = "Constant",
pop15 = "Percentage of population under 15",
pop75 = "Percentage of population over 75",
dpi = "Real per-capita disposable income",
ddpi = "Growth rate of real per-capita disp. income"
))
# This produces output in tab-delimited format:
write.mtable(mtable123)
# }
# NOT RUN {
# This produces output in tab-delimited format:
file123 <- "mtable123.txt"
write.mtable(mtable123,file=file123)
file.show(file123)
# The contents of this file can be pasted into Word
# and converted into a Word table.
# }
# NOT RUN {
texfile123 <- "mtable123.tex"
write.mtable(mtable123,format="LaTeX",file=texfile123)
file.show(texfile123)
# }
# NOT RUN {
#### Examples with UC Berkeley data
berkeley <- Aggregate(Table(Admit,Freq)~.,data=UCBAdmissions)
berk0 <- glm(cbind(Admitted,Rejected)~1,data=berkeley,family="binomial")
berk1 <- glm(cbind(Admitted,Rejected)~Gender,data=berkeley,family="binomial")
berk2 <- glm(cbind(Admitted,Rejected)~Gender+Dept,data=berkeley,family="binomial")
mtable(berk0,summary.stats=c("Deviance","N"))
mtable(berk1,summary.stats=c("Deviance","N"))
mtable(berk0,berk1,berk2,summary.stats=c("Deviance","N"))
mtable(berk0,berk1,berk2,
coef.style="horizontal",
summary.stats=c("Deviance","AIC","N"))
mtable(berk0,berk1,berk2,
coef.style="stat",
summary.stats=c("Deviance","AIC","N"))
mtable(berk0,berk1,berk2,
coef.style="ci",
summary.stats=c("Deviance","AIC","N"))
mtable(berk0,berk1,berk2,
coef.style="ci.se",
summary.stats=c("Deviance","AIC","N"))
mtable(berk0,berk1,berk2,
coef.style="ci.se.horizontal",
summary.stats=c("Deviance","AIC","N"))
mtable(berk0,berk1,berk2,
coef.style="ci.p.horizontal",
summary.stats=c("Deviance","AIC","N"))
mtable(berk0,berk1,berk2,
coef.style="ci.horizontal",
summary.stats=c("Deviance","AIC","N"))
mtable(berk0,berk1,berk2,
coef.style="all",
summary.stats=c("Deviance","AIC","N"))
mtable(berk0,berk1,berk2,
coef.style="all.nostar",
summary.stats=c("Deviance","AIC","N"))
mtable(by(berkeley,berkeley$Dept,
function(x)glm(cbind(Admitted,Rejected)~Gender,
data=x,family="binomial")),
summary.stats=c("Likelihood-ratio","N"))
mtable(By(~Gender,
glm(cbind(Admitted,Rejected)~Dept,
family="binomial"),
data=berkeley),
summary.stats=c("Likelihood-ratio","N"))
berkfull <- glm(cbind(Admitted,Rejected)~Dept/Gender - 1,
data=berkeley,family="binomial")
relabel(mtable(berkfull),Dept="Department",gsub=TRUE)
#### Array-like semantics
mtable123 <- mtable("Model 1"=lm0,"Model 2"=lm1,"Model 3"=lm2,
summary.stats=c("sigma","R-squared","F","p","N"))
dim(mtable123)
dimnames(mtable123)
mtable123[c("dpi","ddpi"),
c("Model 2","Model 3")]
#### Concatention
mt01 <- mtable(lm0,lm1,summary.stats=c("R-squared","N"))
mt12 <- mtable(lm1,lm2,summary.stats=c("R-squared","F","N"))
c(mt01,mt12) # not that this makes sense, but ...
c("Group 1"=mt01,
"Group 2"=mt12)
# }
Run the code above in your browser using DataLab