Description Usage Arguments Details Value Author(s) See Also Examples
Produce well-formatted LaTeX tables of multiple models side-by-side.
*** Requires \usepackage{dcolumn}
in Latex/Sweave preamble. ***
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | apsrtable (...,
se=c("robust","vcov","both","pval"),
model.names=NULL, model.counter=1, digits=2,
stars=1,lev=.05,
align=c("left","center","right"),
order=c("lr","rl","longest"),
notes=list(se.note, stars.note),
omitcoef=NULL,coef.names=NULL,
coef.rows=2,
multicolumn.align=c("center","left","right"),
col.hspace=NULL,
Sweave=FALSE, float="table",
Minionfig=FALSE,
label=NULL,caption=NULL,
caption.position=c("above","below"))
|
... |
One or more fitted model objects of a supported class such
as |
se |
A character string controlling the quantities in parentheses, can take the following values:
If
any model in |
model.names |
Optional vector of names to use as column headings in the table. If more models than names are supplied, unnamed models are numbered (starting at one more than the number of names). |
model.counter |
Change the number to start counting from when using automatically numbered models. Default = 1. |
digits |
Number of decimal places to report. Default = 2 |
stars |
Show statistical significance “stars”, either “1” or
“default” where “default” is based on the output of
|
lev |
When |
align |
How should columns be aligned in the output? Model
summaries are always decimal-aligned using dcolumn (and therefore
also set in math mode), but dcolumn also provides for decimal-point
centering. Model names are set in |
order |
Determines the order in which terms (rows) are included in the output when more than one model (column) is present. “lr” and “rl” take the order of terms from the first or last (leftmost or rightmost) model and appends new terms as they are encountered. “longest” uses the order of terms in the model with the most terms.Default = “lr”. |
notes |
A list to be evaluated and placed, one item per
full-width (multicolumn) line, in footnote size. The default uses
two functions, |
omitcoef |
An optional integer or character vector of
coefficient indices, or an expression involving
|
coef.names |
An optional vector of names for coefficients. It is
recommended to establish the |
coef.rows |
The number of rows in the table given to each
coefficient: by default each coefficient's standard error is printed
in a row beneath it, but setting |
multicolumn.align |
Alignment for the table's |
col.hspace |
Optional |
Sweave |
Toggle whether to include
|
float |
if |
Minionfig |
Include latex command to change the figure style to
“tabular” and back to “proportional”, specifically for the
|
label |
A string to be used as the label in latex for the
table. Used only when |
caption |
A latex string to be used as the caption for the
table (remember to use double backslashes for latex commands in R).
Used only when |
caption.position |
Determines the placement of the caption and
label with respect to the tabular environment. (Not thoroughly tested
with alternative float environments, but should work with the standard
|
Given one or several model objects of various types,
apsrtable()
will produce side-by-side output in well-formatted
LaTeX using either automated numbering or user-supplied model names
and dcolumn
decimal-aligned columns. Terms are matched across
rows, with options for determining the order of terms. Nuisance terms
(e.g. controls, or other quantities not of primary interest) may be
omitted. Standard errors of parameter estimates are placed below
estimates and in parentheses, with the option for the user to supply a
replacement vector of standard errors or a replacement
variance-covariance matrix, such as one estimated using the
sandwich
package. By default a single star denotes statistical
significance at the .05 level, with the option to employ further
decorations or specify another arbitrary level for the test. Finally,
some model diagnostics are included along with a (somewhat) flexible
means to program or include different items depending on model object
class.
The argument omitcoef
suppresses the output of specific rows. It
may be either a valid subscript index (integer or logical if opacity is desired, or
character for transparency), or an expression
, such as a
grep
expression to be evaluated with respect to
coefnames
(without a dot). The internal objectcoefnames
is the union of all model terms, in the desired order
. In the
example below, “(Intercept)” is excluded by a regular
expression matching the parenthesis.
To exclude multiple regular expressions, or a mix of expressions with
other types, you may supply a list, but you must ensure that
the result is a valid subscript list: all character, all numeric, or
all logical. For example, if you refer to a specific coefficient by
its character name, include the argument value=TRUE
in any
grep
expressions in the list.
Model diagnostic information (“model info”) is handled by
formal modelInfo
methods defined for model
summaries. These methods return lists of S3 class model.info
,
named formatted (character) elements. To include fit (or other)
information that is available from fitted model objects but not
their summaries, write an apsrtableSummary
method to
prepare a summary with the items needed for your own modelInfo
method.
Included are modelInfo functions for lm
, glm
, and
tobit
, coxph
,
clogit
, and a
skeleton (incomplete modelInfo
) for gee
and svyglm
objects. Please email the author any
modelInfo
functions you write for different model objects for
inclusion in future releases.
A character vector containing lines of latex code. It can be
written out using writeLines
for inclusion via
\input{}
in latex documents.
Michael Malecki <malecki at wustl.edu>
modelInfo
for changing the model diagnostic
summary information presented and how to include it for different
classes of model objects; notefunctions
for functions to
produce dynamic “notes” beneath tables; and
apsrtableSummary
for creating model summaries that
produce results compatible with what apsrtable
expects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
## Use the example from lm() to show both models:
## Annette Dobson (1990) "An Introduction to Generalized Linear Models".
## Page 9: Plant Weight Data.
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2,10,20, labels=c("Ctl","Trt"))
weight <- c(ctl, trt)
lm.D9 <- lm(weight ~ group)
glm.D9 <- glm(weight~group)
lm.D90 <- lm(weight ~ group - 1) # omitting intercept
apsrtable(lm.D90, lm.D9, glm.D9, digits=1, align="center",
stars="default", model.counter=0, order="rl")
## Not run:
apsrtable(lm.D90, lm.D9, glm.D9, digits=1, align="l",
stars=1, model.counter=0, order="rl",
coef.rows=1, col.hspace="3em", float="sidewaystable")
## Omit rows by regular expressions
apsrtable(lm.D9, omitcoef=expression(grep("\\(",coefnames)))
apsrtable(lm.D90,lm.D9,
omitcoef=list("groupCtl",
expression(grep("\\(",coefnames,value=TRUE))
)
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.