tab_model()
creates HTML tables from regression models.
tab_model(..., transform, show.intercept = TRUE, show.est = TRUE,
show.ci = 0.95, show.hdi50 = TRUE, show.se = NULL, show.std = NULL,
show.p = TRUE, show.stat = FALSE, show.df = FALSE,
show.zeroinf = TRUE, show.r2 = TRUE, show.icc = TRUE,
show.re.var = TRUE, show.fstat = FALSE, show.aic = FALSE,
show.aicc = FALSE, show.dev = FALSE, show.obs = TRUE, terms = NULL,
rm.terms = NULL, group.terms = TRUE, order.terms = NULL, title = NULL,
pred.labels = NULL, dv.labels = NULL, wrap.labels = 25,
string.pred = "Predictors", string.std = "std. Beta", string.ci = "CI",
string.se = "std. Error", string.p = "p", string.df = "df",
string.stat = "Statistic", ci.hyphen = " – ",
minus.sign = "-", collapse.ci = FALSE, collapse.se = FALSE,
linebreak = TRUE, digits = 2, digits.p = 3, emph.p = TRUE,
p.val = c("wald", "kr"), case = "parsed", auto.label = TRUE,
bpe = "median", CSS = css_theme("regression"))
One or more regression models, including glm's or mixed models.
May also be a list
with fitted models. See 'Examples'.
A character vector, naming a function that will be applied
on estimates and confidence intervals. By default, transform
will
automatically use "exp"
as transformation for applicable classes of
regression models (e.g. logistic or poisson regression). Estimates of linear
models remain untransformed. Use NULL
if you want the raw,
non-transformed estimates.
Logical, if TRUE
, the intercepts are printed.
Logical, if TRUE
, the estimates are printed.
Either logical, and if TRUE
, the confidence intervals
is printed to the table; if FALSE
, confidence intervals are
omitted. Or numeric, between 0 and 1, indicating the range of the
confidence intervals.
Logical, if TRUE
, for Bayesian models, a second
credible interval is added to the table output.
Logical, if TRUE
, the standard errors are also printed.
Indicates whether standardized beta-coefficients should also printed, and if yes, which type of standardization is done. See 'Details'.
Logical, if TRUE
, p-values are also printed.
Logical, if TRUE
, the coefficients' test statistic
is also printed.
Logical, if TRUE
and p.val = "kr"
, the p-values
for linear mixed models are based on df with Kenward-Rogers approximation.
These df-values are printed. See p_value
for details.
Logical, if TRUE
and model has a zero-inflated
model part, this is also printed to the table.
Logical, if TRUE
, the r-squared value is also printed.
Depending on the model, these might be pseudo-r-squared values, or Bayesian
r-squared etc. See r2
for details.
Logical, if TRUE
, prints the intraclass correlation
coefficient for mixed models. See icc
for details.
Logical, if TRUE
, prints the random effect variances
for mixed models. See re_var
for details.
Logical, if TRUE
, the F-statistics for each model is
printed in the table summary. This option is not supported by all model types.
Logical, if TRUE
, the AIC value for each model is printed
in the table summary.
Logical, if TRUE
, the second-order AIC value for each model
is printed in the table summary.
Logical, if TRUE
, shows the deviance of the model.
Logical, if TRUE
, the number of observations per model is
printed in the table summary.
Character vector with names of those terms (variables) that should
be printed in the table. All other terms are removed from the output. If
NULL
, all terms are printed. Note that the term names must match
the names of the model's coefficients. For factors, this means that
the variable name is suffixed with the related factor level, and each
category counts as one term. E.g. rm.terms = "t_name [2,3]"
would remove the terms "t_name2"
and "t_name3"
(assuming
that the variable t_name
is categorical and has at least
the factor levels 2
and 3
). Another example for the
iris-dataset: terms = "Species"
would not work, instead
you would terms = "Species [versicolor,virginica]"
.
Character vector with names that indicate which terms should
be removed from the output Counterpart to terms
. rm.terms =
"t_name"
would remove the term t_name. Default is NULL
, i.e.
all terms are used. For factors, levels that should be removed from the plot
need to be explicitely indicated in square brackets, and match the model's
coefficient names, e.g. rm.terms = "t_name [2,3]"
would remove the terms
"t_name2"
and "t_name3"
(assuming that the variable t_name
was categorical and has at least the factor levels 2
and 3
).
Logical, if TRUE
(default), automatically groups table rows with
factor levels of same factor, i.e. predictors of type factor
will
be grouped, if the factor has more than two levels. Grouping means that a separate headline
row is inserted to the table just before the predictor values.
Numeric vector, indicating in which order the coefficients should be plotted. See examples in this package-vignette.
String, will be used as table caption.
Character vector with labels of predictor variables.
If not NULL
, pred.labels
will be used in the first
table column with the predictors' names. By default, if auto.label = TRUE
and get_term_labels
is called to retrieve the labels
of the coefficients, which will be used as predictor labels.
If pred.labels = ""
or auto.label = FALSE
, the raw
variable names as used in the model formula are used as predictor
labels. If pred.labels
is a named vector, predictor labels (by
default, the names of the model's coefficients) will be matched with the
names of pred.labels
. This ensures that labels always match the
related predictor in the table, no matter in which way the predictors
are sorted. See 'Examples'.
Character vector with labels of dependent variables of all fitted models. See 'Examples'.
Numeric, determines how many chars of the value, variable or axis labels are displayed in one line and when a line break is inserted.
Character vector,used as headline for the predictor column.
Default is "Predictors"
.
Character vector, used for the column heading of standardized beta coefficients. Default is "std. Beta"
.
Character vector, used for the column heading of confidence interval values. Default is "CI"
.
Character vector, used for the column heading of standard error values. Default is "std. Error"
.
Character vector, used for the column heading of p values. Default is "p"
.
Character vector, used for the column heading of degrees of freedom. Default is "df"
.
Character vector, used for the test statistic. Default is "Statistic"
.
Character vector, indicating the hyphen for confidence interval range. May be an HTML entity. See 'Examples'.
string, indicating the minus sign for negative numbers. May be an HTML entity. See 'Examples'.
Logical, if FALSE
, the CI values are shown in
a separate table column.
Logical, if FALSE
, the SE values are shown in
a separate table column.
Logical, if TRUE
and collapse.ci = FALSE
or
collapse.se = FALSE
, inserts a line break between estimate and
CI resp. SE values. If FALSE
, values are printed in the same line
as estimate values.
Amount of decimals for estimates
Amount of decimals for p-values
Logical, if TRUE
, significant p-values are shown bold faced.
Character, for mixed models, indicates how p-values are computed.
Use p.val = "wald"
for a faster, but less precise computation. For
p.val = "kr"
, computation of p-values is based on conditional F-tests
with Kenward-Roger approximation for the degrees of freedom, using the
pbkrtest-package. In this case, use show.df = TRUE
to show
the approximated degrees of freedom for each coefficient.
Desired target case. Labels will automatically converted into the
specified character case. See to_any_case
for more
details on this argument. By default, if case
is not specified,
it will be set to "parsed"
, unless prefix.labels
is not
"none"
. If prefix.labels
is either "label"
(or
"l"
) or "varname"
(or "v"
) and case
is not
specified, it will be set to NULL
- this is a more convenient
default when prefixing labels.
Logical, if TRUE
(the default), plot-labels are
based on value and variable labels, if the data is labelled. See
get_label
and
get_term_labels
for details. If FALSE
,
original variable names and value labels (factor levels) are used.
For Stan-models (fitted with the rstanarm- or
brms-package), the Bayesian point estimate is, by default, the median
of the posterior distribution. Use bpe
to define other functions to
calculate the Bayesian point estimate. bpe
needs to be a character
naming the specific function, which is passed to the fun
-argument in
typical_value
. So, bpe = "mean"
would
calculate the mean value of the posterior distribution.
A list
with user-defined style-sheet-definitions,
according to the official CSS syntax.
See 'Details' or this package-vignette.
Invisibly returns
the web page style sheet (page.style
),
the web page content (page.content
),
the complete html-output (page.complete
) and
the html-table with inline-css for use with knitr (knitr
)
for further use.
Standardized Estimates
Concerning the show.std
argument, show.std = "std"
will print normal standardized estimates. For show.std = "std2"
,
however, standardization of estimates follows
Gelman's (2008)
suggestion, rescaling the estimates by dividing them by two standard
deviations instead of just one. Resulting coefficients are then
directly comparable for untransformed binary predictors. This type
of standardization uses the standardize
-function
from the arm-package.
For backward compatibility reasons, show.std
also may be
a logical value; if TRUE
, normal standardized estimates are
printed (same effect as show.std = "std"
). Use
show.std = NULL
(default) or show.std = FALSE
,
if standardized estimats should not be printed.
How do I use CSS
-argument?
With the CSS
-argument, the visual appearance of the tables
can be modified. To get an overview of all style-sheet-classnames
that are used in this function, see return value page.style
for details.
Arguments for this list have following syntax:
the class-names with "css."
-prefix as argument name and
each style-definition must end with a semicolon
You can add style information to the default styles by using a + (plus-sign) as initial character for the argument attributes. Examples:
css.table = 'border:2px solid red;'
for a solid 2-pixel table border in red.
css.summary = 'font-weight:bold;'
for a bold fontweight in the summary row.
css.lasttablerow = 'border-bottom: 1px dotted blue;'
for a blue dotted border of the last table row.
css.colnames = '+color:green'
to add green color formatting to column names.
css.arc = 'color:blue;'
for a blue text color each 2nd row.
css.caption = '+color:red;'
to add red font-color to the default table caption style.