regTable | R Documentation |
regTable()
takes a list of regression objects, such as those created
by lm()
. It returns a matrix in which the columns are estimates and
standard errors – two columns for each model. Together, the two columns
that represent a regression are a column-pair or a
column-tier.
regTable( objList, colNames = NULL, rowsToRemove = NULL, rowsToKeep = NULL, clusterVar = NULL )
objList |
List of regression objects. This is the only required
argument. |
colNames |
A vector of strings as long as |
rowsToRemove |
A vector of strings, which may specify regular
expressions. Variables in the regressions whose names match the strings will
be omitted from the |
rowsToKeep |
A vector of strings, which may specify regular
expressions. Variables in the regressions whose names match the strings will
be kept in the |
clusterVar |
Either |
A matrix in which the columns are estimates and
standard errors – two columns for each model. The matrix has an "N"
attribute that indicates the number of observations for each regression. If
all regressions were of class lm
(but not also class glm
), it
also has the "r.squared" and "SER" attributes. (The "SER" attribute
indicates the standard error of regression – AKA σ or the
"residual standard error" — for each model.)
[
operatorYou can take subsets of regTable objects with the [
operator. It subsets
intelligently. That is, it knows whether the subsetted object
contains only intact column tiers, and it modifies the class and attributes
of the subsetted object accordingly. To wit:
If you remove only certain column-pairs from your original regTable
object, such that the remaining columns all form intact column-pairs, all
attributes for the remaining column-tiers are preserved. For example, the
N
and r.squared
attributes are preserved. In other words,
the [
operator knows which regressions you have removed from the table,
and it removes attribute information for only those regressions.
If you remove only rows from your original regTable object, all
attributes are preserved. This result has the potential to be misleading:
for example, you may remove a row that reports information for a given
predictor, but the N
, r.squared
, and SER
attributes were all
computed from regressions that included that predictor. Consequently, a
message will be printed to remind you that the attributes have been
preserved.
If you remove columns from your original regTable object such that the
remaining columns do not all form intact column-pairs, the N
,
r.squared
, and SER
attributes are stripped, and the returned object is
a matrix without the "regTable" class.
See the examples for an illustration.
Before regTable()
was incorporated into this package,
it used the rowsToKeep
argument differently: variables were kept
only if the beginnings of their names matched the strings in
rowsToKeep
.
Other functions for making tables: \linkIntlatexTable, \linkIntlatexTablePDF. See also the Building better tables in less time vignette.
data(iris) lm1 <- lm(Sepal.Length ~ Petal.Length, data = iris) lm2 <- lm(Sepal.Length ~ Petal.Length + Petal.Width, data = iris) regTable(list(lm1, lm2)) regTable(list(lm1, lm2), colNames = c("Sepal length", "Sepal width")) regTable(list(lm1, lm2), rowsToKeep = 'Length') regTable(list(lm1, lm2), rowsToKeep = c('Intercept', 'Length')) regTable(list(lm1, lm2), clusterVar = list(iris$Species)) # illustrate subsetting rT <- regTable(list(lm1, lm2)) ncol(rT) # 4 attributes(rT)$N # 150 150 rT2 <- rT[1:2, ] attributes(rT2)$N # 150 150 rT3 <- rT[, 3:4] attributes(rT3)$N # 150 rT4 <- rT[, 2:3] attributes(rT4)$N # NULL class(rT4) # "matrix"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.