*** Requires \usepackage{dcolumn}
in Latex/Sweave preamble. ***
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"))
lm
or glm
. The model-object (a list
) may
also optionally contain an item named se
: model$se
may
be a vector of standard errors, or a variance-covariance matrix, in
which case the square root of the diagonal is used as the
robust standard errors in the output. See the se
argument.
$se
element appended to the
model object.
coef(summary(model))
. This behavior may be
useful in writing apsrtableSummary
methods to
customize output or format new model classes.
coef(summary(model))
. Quietly switches
se.note
to say (Robust) $p$ values in
parentheses. Robust values are used (and so labeled contextually)
whenever an $se
element is present in any model. If
any model in ...
contains an se
element and
robust is chosen (the default), output is labeled as
robust; if no models have an se
element (all use
model vcov) but se="robust"
, labeling is simply
Standard errors in parentheses. Default = "robust"
summary.lm
, except that a superscript dagger is used instead
of a dot for $p < .10$. Here default means the R default, not to be confused with the function's (perhaps confusing)
Default=1stars=1
, what level should be used
for the test to reject statistical insignificance and bestow the
glittering star? Disable decoration entirely by specifying
lev=0
. Default=.05.\multicolumn
spans with
alignment given here, as are model terms (leftmost column of
table). Default = left.se.note
and stars.note
to
generate notes about the standard errors and indicators of
statistical significance. Other notes can be named function calls or
simple character strings.coefnames
that evaluates to integer or
character, of rows to exclude from the output. See details. omitcoef
and order
settings with automatic symbolic naming before supplying a vector of
pretty variable names. If automatic symbolic naming is
used, names are taken from the variables in the models and
sanitized for latex. If coef.names
are supplied, they
must be valid latex, with double-backslash escape characters.coef.rows
to 1 places it in
a new column to the right instead.multicolumn
spans: typically only the model names at the top, but, in the case of
coef.rows=1
, the model.info
is also aligned beneath both
columns. Default=centerhspace
(number+tex units such as
em
) to insert between each model column(s). Intended mainly to
separate models from each other when coef.rows=1
. Default=NULL\begin{table}...\end{table}
, label, and caption, or only the
\begin{tabular} ... \end{tabular}
. When called from within an
Sweave
document one would typically write such elements in the
documentation (latex-part) rather than inside the code
chunk. When called from an Sweave
document, make sure to set
the code chunk option results=tex
. Default = FALSESweave
is false -- that is, if apsrtable
is supposed to wrap the output in the float environment, float
allows you to specify an arbitrary custom float environment. Some
useful ones include sidewaystable (latex package
rotating), or longtable. In the special case of
longtable, the header row of model names is included on all
pages, and the label
and caption
arguments are included
even when Sweave=TRUE
because of the structure of the
latex environment.MinionPro
latex package. Default = FALSESweave=FALSE
, unless
float="longtable"
.Sweave=FALSE
, unless float="longtable"
.table/tabular
combination.) Default="above"
writeLines
for inclusion via
\input{}
in latex documents.
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.
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. ## 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)
Run the code above in your browser using DataLab