View source: R/print.parameters_model.R
format.parameters_model | R Documentation |
A print()
-method for objects from model_parameters()
.
## S3 method for class 'parameters_model'
format(
x,
pretty_names = TRUE,
split_components = TRUE,
select = NULL,
digits = 2,
ci_digits = digits,
p_digits = 3,
ci_width = NULL,
ci_brackets = NULL,
zap_small = FALSE,
format = NULL,
groups = NULL,
include_reference = FALSE,
...
)
## S3 method for class 'parameters_model'
print(
x,
pretty_names = TRUE,
split_components = TRUE,
select = NULL,
caption = NULL,
footer = NULL,
digits = 2,
ci_digits = digits,
p_digits = 3,
footer_digits = 3,
show_sigma = FALSE,
show_formula = FALSE,
zap_small = FALSE,
groups = NULL,
column_width = NULL,
ci_brackets = c("[", "]"),
include_reference = FALSE,
...
)
## S3 method for class 'parameters_model'
summary(object, ...)
## S3 method for class 'parameters_model'
print_html(
x,
pretty_names = TRUE,
split_components = TRUE,
select = NULL,
caption = NULL,
subtitle = NULL,
footer = NULL,
align = NULL,
digits = 2,
ci_digits = digits,
p_digits = 3,
footer_digits = 3,
ci_brackets = c("(", ")"),
show_sigma = FALSE,
show_formula = FALSE,
zap_small = FALSE,
groups = NULL,
font_size = "100%",
line_padding = 4,
column_labels = NULL,
include_reference = FALSE,
verbose = TRUE,
...
)
## S3 method for class 'parameters_model'
print_md(
x,
pretty_names = TRUE,
split_components = TRUE,
select = NULL,
caption = NULL,
subtitle = NULL,
footer = NULL,
align = NULL,
digits = 2,
ci_digits = digits,
p_digits = 3,
footer_digits = 3,
ci_brackets = c("(", ")"),
show_sigma = FALSE,
show_formula = FALSE,
zap_small = FALSE,
groups = NULL,
include_reference = FALSE,
verbose = TRUE,
...
)
x , object |
An object returned by |
pretty_names |
Can be |
split_components |
Logical, if |
select |
Determines which columns and and which layout columns are printed. There are three options for this argument:
There are two pre-defined options for selecting columns:
It is possible to create multiple columns as well. A If
- `"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})"`.. - `"ci_p2"`: Estimates, confidence intervals and numeric p-values, in two columns. This is equivalent to `select = "{estimate} ({ci})|{p}"`. - `"se_p2"`: Estimate, standard errors and numeric p-values, in two columns. This is equivalent to `select = "{estimate} ({se})|{p}"`. For |
digits , ci_digits , p_digits |
Number of digits for rounding or
significant figures. May also be |
ci_width |
Minimum width of the returned string for confidence
intervals. If not |
ci_brackets |
Logical, if |
zap_small |
Logical, if |
format |
String, indicating the output format. Can be |
groups |
Named list, can be used to group parameters in the printed output.
List elements may either be character vectors that match the name of those
parameters that belong to one group, or list elements can be row numbers
of those parameter rows that should belong to one group. The names of the
list elements will be used as group names, which will be inserted as "header
row". A possible use case might be to emphasize focal predictors and control
variables, see 'Examples'. Parameters will be re-ordered according to the
order used in |
include_reference |
Logical, if |
... |
Arguments passed down to |
caption |
Table caption as string. If |
footer |
Can either be |
footer_digits |
Number of decimal places for values in the footer summary. |
show_sigma |
Logical, if |
show_formula |
Logical, if |
column_width |
Width of table columns. Can be either |
subtitle |
Table title (same as caption) and subtitle, as strings. If |
align |
Only applies to HTML tables. May be one of |
font_size |
For HTML tables, the font size. |
line_padding |
For HTML tables, the distance (in pixel) between lines. |
column_labels |
Labels of columns for HTML tables. If |
verbose |
Toggle messages and warnings. |
summary()
is a convenient shortcut for
print(object, select = "minimal", show_sigma = TRUE, show_formula = TRUE)
.
Invisibly returns the original input object.
The verbose
argument can be used to display or silence messages and
warnings for the different functions in the parameters package. However,
some messages providing additional information can be displayed or suppressed
using options()
:
parameters_info
: options(parameters_info = TRUE)
will override the
include_info
argument in model_parameters()
and always show the model
summary for non-mixed models.
parameters_mixed_info
: options(parameters_mixed_info = TRUE)
will
override the include_info
argument in model_parameters()
for mixed
models, and will then always show the model summary.
parameters_cimethod
: options(parameters_cimethod = TRUE)
will show the
additional information about the approximation method used to calculate
confidence intervals and p-values. Set to FALSE
to hide this message when
printing model_parameters()
objects.
parameters_exponentiate
: options(parameters_exponentiate = TRUE)
will
show the additional information on how to interpret coefficients of models
with log-transformed response variables or with log-/logit-links when the
exponentiate
argument in model_parameters()
is not TRUE
. Set this option
to FALSE
to hide this message when printing model_parameters()
objects.
There are further options that can be used to modify the default behaviour for printed outputs:
parameters_labels
: options(parameters_labels = TRUE)
will use variable
and value labels for pretty names, if data is labelled. If no labels
available, default pretty names are used.
parameters_interaction
: options(parameters_interaction = <character>)
will replace the interaction mark (by default, *
) with the related character.
parameters_select
: options(parameters_select = <value>)
will set the
default for the select
argument. See argument's documentation for available
options.
easystats_html_engine
: options(easystats_html_engine = "gt")
will set
the default HTML engine for tables to gt
, i.e. the gt package is used to
create HTML tables. If set to tt
, the tinytable package is used.
insight_use_symbols
: options(insight_use_symbols = TRUE)
will try to
print unicode-chars for symbols as column names, wherever possible (e.g.,
ω instead of Omega
).
Note that the interpretation of interaction terms depends on many
characteristics of the model. The number of parameters, and overall
performance of the model, can differ or not between a * b
,
a : b
, and a / b
, suggesting that sometimes interaction terms
give different parameterizations of the same model, but other times it gives
completely different models (depending on a
or b
being factors
of covariates, included as main effects or not, etc.). Their interpretation
depends of the full context of the model, which should not be inferred
from the parameters table alone - rather, we recommend to use packages
that calculate estimated marginal means or marginal effects, such as
modelbased, emmeans, ggeffects, or
marginaleffects. To raise awareness for this issue, you may use
print(...,show_formula=TRUE)
to add the model-specification to the output
of the print()
method for model_parameters()
.
Throughout the parameters package, we decided to label the residual
degrees of freedom df_error. The reason for this is that these degrees
of freedom not always refer to the residuals. For certain models, they refer
to the estimate error - in a linear model these are the same, but in - for
instance - any mixed effects model, this isn't strictly true. Hence, we
think that df_error
is the most generic label for these degrees of
freedom.
See also display()
.
library(parameters)
model <- glmmTMB::glmmTMB(
count ~ spp + mined + (1 | site),
ziformula = ~mined,
family = poisson(),
data = Salamanders
)
mp <- model_parameters(model)
print(mp, pretty_names = FALSE)
print(mp, split_components = FALSE)
print(mp, select = c("Parameter", "Coefficient", "SE"))
print(mp, select = "minimal")
# group parameters ------
data(iris)
model <- lm(
Sepal.Width ~ Sepal.Length + Species + Petal.Length,
data = iris
)
# don't select "Intercept" parameter
mp <- model_parameters(model, parameters = "^(?!\\(Intercept)")
groups <- list(
"Focal Predictors" = c("Speciesversicolor", "Speciesvirginica"),
"Controls" = c("Sepal.Length", "Petal.Length")
)
print(mp, groups = groups)
# or use row indices
print(mp, groups = list(
"Focal Predictors" = c(1, 4),
"Controls" = c(2, 3)
))
# only show coefficients, CI and p,
# put non-matched parameters to the end
data(mtcars)
mtcars$cyl <- as.factor(mtcars$cyl)
mtcars$gear <- as.factor(mtcars$gear)
model <- lm(mpg ~ hp + gear * vs + cyl + drat, data = mtcars)
# don't select "Intercept" parameter
mp <- model_parameters(model, parameters = "^(?!\\(Intercept)")
print(mp, groups = list(
"Engine" = c("cyl6", "cyl8", "vs", "hp"),
"Interactions" = c("gear4:vs", "gear5:vs")
))
# custom column layouts ------
data(iris)
lm1 <- lm(Sepal.Length ~ Species, data = iris)
lm2 <- lm(Sepal.Length ~ Species + Petal.Length, data = iris)
# custom style
result <- compare_parameters(lm1, lm2, select = "{estimate}{stars} ({se})")
print(result)
# custom style, in HTML
result <- compare_parameters(lm1, lm2, select = "{estimate}<br>({se})|{p}")
print_html(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.