print.estimate_contrasts | R Documentation |
Printing modelbased-objects
Description
print()
method for modelbased objects. Can be used to tweak the output
of tables.
Usage
## S3 method for class 'estimate_contrasts'
print(
x,
select = getOption("modelbased_select", NULL),
include_grid = getOption("modelbased_include_grid", FALSE),
full_labels = getOption("modelbased_full_labels", TRUE),
...
)
Arguments
x |
An object returned by the different estimate_*() functions.
|
select |
Determines which columns are printed and the table layout.
There are two options for this argument:
-
A string expression with layout pattern
select is a string with "tokens" enclosed in braces. These tokens will be
replaced by their associated columns, where the selected columns will be
collapsed into one column. Following tokens are replaced by the related
coefficients or statistics: {estimate} , {se} , {ci} (or {ci_low} and
{ci_high} ), {p} , {pd} and {stars} . The token {ci} will be replaced
by {ci_low}, {ci_high} . Example: select = "{estimate}{stars} ({ci})"
It is possible to create multiple columns as well. A | separates values
into new cells/columns. Example: select = "{estimate} ({ci})|{p}" .
-
A string indicating a pre-defined layout
select can be one of the following string values, to create one of the
following pre-defined column layouts:
-
"minimal" : Estimates, confidence intervals and numeric p-values, in two
columns. This is equivalent to select = "{estimate} ({ci})|{p}" .
-
"short" : Estimate, standard errors and numeric p-values, in two columns.
This is equivalent to select = "{estimate} ({se})|{p}" .
-
"ci" : Estimates and confidence intervals, no asterisks for p-values.
This is equivalent to select = "{estimate} ({ci})" .
-
"se" : Estimates and standard errors, no asterisks for p-values. This is
equivalent to select = "{estimate} ({se})" .
-
"ci_p" : Estimates, confidence intervals and asterisks for p-values. This
is equivalent to select = "{estimate}{stars} ({ci})" .
-
"se_p" : Estimates, standard errors and asterisks for p-values. This is
equivalent to select = "{estimate}{stars} ({se})" ..
Using select to define columns will re-order columns and remove all columns
related to uncertainty (standard errors, confidence intervals), test statistics,
and p-values (and similar, like pd or BF for Bayesian models), because
these are assumed to be included or intentionally excluded when using select .
The new column order will be: Parameter columns first, followed by the "glue"
columns, followed by all remaining columns. If further columns should also be
placed first, add those as focal_terms attributes to x . I.e., following
columns are considers as "parameter columns" and placed first:
c(easystats_columns("parameter"), attributes(x)$focal_terms) .
Note: glue-like syntax is still experimental in the case of more complex models
(like mixed models) and may not return expected results.
|
include_grid |
Logical, if TRUE , the data grid is included in the
table output. Only applies to prediction-functions like estimate_relation()
or estimate_link() .
|
full_labels |
Logical, if TRUE (default), all labels for focal terms
are shown. If FALSE , redundant (duplicated) labels are removed from rows.
|
... |
Arguments passed to insight::format_table() or
insight::export_table() .
|
Value
Invisibly returns x
.
Global Options to Customize Tables when Printing
Columns and table layout can be customized using options()
:
-
modelbased_select
: options(modelbased_select = <string>)
will set a
default value for the select
argument and can be used to define a custom
default layout for printing.
-
modelbased_include_grid
: options(modelbased_include_grid = TRUE)
will
set a default value for the include_grid
argument and can be used to
include data grids in the output by default or not.
-
modelbased_full_labels
: options(modelbased_full_labels = FALSE)
will
remove redundant (duplicated) labels from rows.
Note
Use print_html()
and print_md()
to create tables in HTML or
markdown format, respectively.
Examples
model <- lm(Petal.Length ~ Species, data = iris)
out <- estimate_means(model, "Species")
# default
print(out)
# smaller set of columns
print(out, select = "minimal")
# remove redundant labels
data(efc, package = "modelbased")
efc <- datawizard::to_factor(efc, c("c161sex", "c172code", "e16sex"))
levels(efc$c172code) <- c("low", "mid", "high")
fit <- lm(neg_c_7 ~ c161sex * c172code * e16sex, data = efc)
out <- estimate_means(fit, c("c161sex", "c172code", "e16sex"))
print(out, full_labels = FALSE, select = "{estimate} ({se})")