Learn R Programming

memisc (version 0.11-11)

mtable: Publication-ready tables of model estimates

Description

mtable produces a table of estimates for several models in a format typically required for social science publications.

Usage

mtable(...,coef.style=getOption("coef.style"),
           summary.stats=TRUE,
           factor.style=getOption("factor.style"),
           getSummary=function(obj,...)UseMethod("getSummary"),
           float.style=getOption("float.style"),
           digits=min(3,getOption("digits")))

## S3 method for class 'mtable': format(x, coef.title="Coefficients", summary.title="Summaries", colsep="\t", rowsep="\n", trim=TRUE, trimleft=trim, trimright=trim, center.at=NULL, align.integers=c("dot","right","left"), topsep="", bottomsep="", sectionsep="", forLaTeX=FALSE, useDcolumn=TRUE, colspec=if(useDcolumn) paste("D{.}{",LaTeXdec,"}{",ddigits,"}",sep="") else "r", LaTeXdec=".", ddigits="-1", useBooktabs=TRUE, toprule=if(useBooktabs) "\toprule" else "\hline\hline", midrule=if(useBooktabs) "\midrule" else "\hline", bottomrule=if(useBooktabs) "\bottomrule" else "\hline\hline", interaction.sep = if(forLaTeX) " $\times$ " else " x ", ... )

## S3 method for class 'mtable': print(x,trim=FALSE,center.at=getOption("OutDec"), colsep=" ", topsep="=",bottomsep="=",sectionsep="-",...)

## S3 method for class 'mtable': toLatex(object,...)

write.mtable(object,file="",...)

## S3 method for class 'mtable': relabel(x,...)

Arguments

...
as argument to mtable: several model objects, e.g. of class lm; as argument to print.mtable, toLatex.mtable, write.mtable: further arguments passed t
coef.style
a character string which specifies the style of coefficient values, whether standard errors, Wald/t-statistics, or significance levels are reported, etc. See coef.style.
summary.stats
if FALSE, no summary statistics are repored. If TRUE, all summary statistics produced by getSummary are reported. This argument may also contain a character vector with the names of th
factor.style
a character string that specifies the style in which factor contrasts are labled. See factor.style.
getSummary
a function that computes model-related statistics that appear in the table. See getSummary.
float.style
default format for floating point numbers if no format is specified by coef.style; see {float.style}.
digits
number of significant digits if not specified by the template returned from getCoefTemplate getSummaryTemplate
x, object
an object of class mtable
coef.title
a character vector, the title for the reported coefficients.
summary.title
a character vector, the title for the reported model summaries.
colsep
a character string which seperates the columns in the output.
rowsep
a character string which seperates the rows in the output.
trim
should leading and trailing spaces be trimmed?
trimleft
should leading spaces be trimmed?
trimright
should trailing spaces be trimmed?
center.at
a character string on which resulting values are centered. Typically equal to ".". This is the default when forLaTeX==TRUE. If NULL, reported values are not centered.
align.integers
how to align integer values.
topsep
a character string that is recycled to a top rule.
bottomsep
a character string that is recycled to a bottom rule.
sectionsep
a character string that is recycled to seperate coefficients from summary statistics.
forLaTeX
should LaTeX code be produced?
useDcolumn
should the dcolumn LaTeX package be used?
colspec
LaTeX table column format specifyer(s).
LaTeXdec
the decimal point in the final LaTeX output.
ddigits
alignment specification or digits after the decimal point.
useBooktabs
should the booktabs LaTeX package be used?
toprule
appearance of the top border of the LaTeX tabular environment.
midrule
how are coefficients and summary statistics separated in the LaTeX tabular environment.
bottomrule
appearance of the bottom border of the LaTeX tabular environment.
interaction.sep
a character string that separates factors that are involved in an interaction effect
file
a file where to write to; defaults to console output.

Value

  • A call to mtable results in an object that inherits from mtable with the following components:
  • coefficientsan array that contains the model coefficients.
  • summariesa matrix that contains the model summaries.
  • In addition the mtable object has attributes as.row, as.col, kill.col, kill.header, and coef.dim necessary for formatting.

Details

mtable constructs a table of estimates for regression-type models. format.mtable formats suitable for use with output or conversion functions such as print.mtable, toLatex.mtable, or write.mtable.

Examples

Run this code
lm0 <- lm(sr ~ pop15 + pop75,              data = LifeCycleSavings)
lm1 <- lm(sr ~                 dpi + ddpi, data = LifeCycleSavings)
lm2 <- lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings)

(mtable123 <- mtable("Model 1"=lm0,"Model 2"=lm1,"Model 3"=lm2))


# Some other output formats

write.mtable(mtable123)
file123 <- "mtable123.txt"
write.mtable(mtable123,file=file123)
file.show(file123)
toLatex(mtable123)
texfile123 <- "mtable123.tex"
cat(toLatex(mtable123),sep="\n",file=texfile123)
file.show(texfile123)

berkeley <- aggregate(wtable(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,berk1,berk2)


mtable(berk0,berk1,berk2,coef.style="stat")
mtable(berk0,berk1,berk2,coef.style="ci")
mtable(berk0,berk1,berk2,coef.style="ci.vertical")
mtable(berk0,berk1,berk2,coef.style="ci.horizontal")
mtable(berk0,berk1,berk2,coef.style="all")
mtable(berk0,berk1,berk2,coef.style="all.nostar")

mtable(by(berkeley,berkeley$Dept,function(x)glm(cbind(Admitted,Rejected)~Gender,data=x,family="binomial")))



mtable(By(~Gender,glm(cbind(Admitted,Rejected)~Dept,family="binomial"),data=berkeley))

Run the code above in your browser using DataLab