1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tab_model.R
\name{tab_model}
\alias{tab_model}
\title{Print regression models as HTML table}
\usage{
tab_model(
...,
transform,
show.intercept = TRUE,
show.est = TRUE,
show.ci = 0.95,
show.ci50 = FALSE,
show.se = NULL,
show.std = NULL,
std.response = TRUE,
show.p = TRUE,
show.stat = FALSE,
show.df = FALSE,
show.zeroinf = TRUE,
show.r2 = TRUE,
show.icc = TRUE,
show.re.var = TRUE,
show.ngroups = TRUE,
show.fstat = FALSE,
show.aic = FALSE,
show.aicc = FALSE,
show.dev = FALSE,
show.loglik = FALSE,
show.obs = TRUE,
show.reflvl = FALSE,
terms = NULL,
rm.terms = NULL,
order.terms = NULL,
keep = NULL,
drop = NULL,
title = NULL,
pred.labels = NULL,
dv.labels = NULL,
wrap.labels = 25,
bootstrap = FALSE,
iterations = 1000,
seed = NULL,
robust = FALSE,
vcov.fun = NULL,
vcov.type = NULL,
vcov.args = NULL,
string.pred = "Predictors",
string.est = "Estimate",
string.std = "std. Beta",
string.ci = "CI",
string.se = "std. Error",
string.std_se = "standardized std. Error",
string.std_ci = "standardized CI",
string.p = "p",
string.std.p = "std. p",
string.df = "df",
string.stat = "Statistic",
string.std.stat = "std. Statistic",
string.resp = "Response",
string.intercept = "(Intercept)",
strings = NULL,
ci.hyphen = " – ",
minus.sign = "-",
collapse.ci = FALSE,
collapse.se = FALSE,
linebreak = TRUE,
col.order = c("est", "se", "std.est", "std.se", "ci", "std.ci", "ci.inner", "ci.outer",
"stat", "std.stat", "p", "std.p", "df.error", "response.level"),
digits = 2,
digits.p = 3,
digits.rsq = 3,
digits.re = 2,
emph.p = TRUE,
p.val = NULL,
df.method = NULL,
p.style = c("numeric", "stars", "numeric_stars", "scientific", "scientific_stars"),
p.threshold = c(0.05, 0.01, 0.001),
p.adjust = NULL,
case = "parsed",
auto.label = TRUE,
prefix.labels = c("none", "varname", "label"),
bpe = "median",
CSS = css_theme("regression"),
file = NULL,
use.viewer = TRUE,
encoding = "UTF-8"
)
}
\arguments{
\item{...}{One or more regression models, including glm's or mixed models.
May also be a \code{list} with fitted models. See 'Examples'.}
\item{transform}{A character vector, naming a function that will be applied
on estimates and confidence intervals. By default, \code{transform} will
automatically use \code{"exp"} as transformation for applicable classes of
\code{model} (e.g. logistic or poisson regression). Estimates of linear
models remain untransformed. Use \code{NULL} if you want the raw,
non-transformed estimates.}
\item{show.intercept}{Logical, if \code{TRUE}, the intercepts are printed.}
\item{show.est}{Logical, if \code{TRUE}, the estimates are printed.}
\item{show.ci}{Either logical, and if \code{TRUE}, the confidence intervals
is printed to the table; if \code{FALSE}, confidence intervals are
omitted. Or numeric, between 0 and 1, indicating the range of the
confidence intervals.}
\item{show.ci50}{Logical, if \code{TRUE}, for Bayesian models, a second
credible interval is added to the table output.}
\item{show.se}{Logical, if \code{TRUE}, the standard errors are
also printed. If robust standard errors are required, use arguments
\code{vcov.fun}, \code{vcov.type} and \code{vcov.args} (see
\code{\link[parameters]{standard_error}} for details).}
\item{show.std}{Indicates whether standardized beta-coefficients should
also printed, and if yes, which type of standardization is done.
See 'Details'.}
\item{std.response}{Logical, whether the response variable will also be
standardized if standardized coefficients are requested. Setting both
\code{std.response = TRUE} and \code{show.std = TRUE} will behave as if
the complete data was standardized before fitting the model.}
\item{show.p}{Logical, if \code{TRUE}, p-values are also printed.}
\item{show.stat}{Logical, if \code{TRUE}, the coefficients' test statistic
is also printed.}
\item{show.df}{Logical, if \code{TRUE} and \code{p.val = "kr"}, the p-values
for linear mixed models are based on df with Kenward-Rogers approximation.
These df-values are printed. See \code{\link[parameters]{p_value}} for details.}
\item{show.zeroinf}{Logical, if \code{TRUE} and model has a zero-inflated
model part, this is also printed to the table.}
\item{show.r2}{Logical, if \code{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 \code{\link[performance]{r2}} for details.}
\item{show.icc}{Logical, if \code{TRUE}, prints the intraclass correlation
coefficient for mixed models. See \code{\link[performance]{icc}} for details.}
\item{show.re.var}{Logical, if \code{TRUE}, prints the random effect variances
for mixed models. See \code{\link[insight]{get_variance}} for details.}
\item{show.ngroups}{Logical, if \code{TRUE}, shows number of random effects groups
for mixed models.}
\item{show.fstat}{Logical, if \code{TRUE}, the F-statistics for each model is
printed in the table summary. This option is not supported by all model types.}
\item{show.aic}{Logical, if \code{TRUE}, the AIC value for each model is printed
in the table summary.}
\item{show.aicc}{Logical, if \code{TRUE}, the second-order AIC value for each model
is printed in the table summary.}
\item{show.dev}{Logical, if \code{TRUE}, shows the deviance of the model.}
\item{show.loglik}{Logical, if \code{TRUE}, shows the log-Likelihood of the model.}
\item{show.obs}{Logical, if \code{TRUE}, the number of observations per model is
printed in the table summary.}
\item{show.reflvl}{Logical, if \code{TRUE}, an additional row is inserted to
the table before each predictor of type \code{\link{factor}}, which will
indicate the reference level of the related factor.}
\item{terms}{Character vector with names of those terms (variables) that should
be printed in the table. All other terms are removed from the output. If
\code{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. \code{rm.terms = "t_name [2,3]"}
would remove the terms \code{"t_name2"} and \code{"t_name3"} (assuming
that the variable \code{t_name} is categorical and has at least
the factor levels \code{2} and \code{3}). Another example for the
\emph{iris}-dataset: \code{terms = "Species"} would not work, instead
use \code{terms = "Species [versicolor,virginica]"}.}
\item{rm.terms}{Character vector with names that indicate which terms should
be removed from the output Counterpart to \code{terms}. \code{rm.terms =
"t_name"} would remove the term \emph{t_name}. Default is \code{NULL}, i.e.
all terms are used. For factors, levels that should be removed from the plot
need to be explicitly indicated in square brackets, and match the model's
coefficient names, e.g. \code{rm.terms = "t_name [2,3]"} would remove the terms
\code{"t_name2"} and \code{"t_name3"} (assuming that the variable \code{t_name}
was categorical and has at least the factor levels \code{2} and \code{3}).}
\item{order.terms}{Numeric vector, indicating in which order the coefficients
should be plotted. See examples in
\href{https://strengejacke.github.io/sjPlot/articles/plot_model_estimates.html}{this package-vignette}.}
\item{keep, drop}{Character containing a regular expression pattern that
describes the parameters that should be included (for \code{keep}) or excluded
(for \code{drop}) in the returned data frame. \code{keep} may also be a
named list of regular expressions. All non-matching parameters will be
removed from the output. If \code{keep} has more than one element, these
will be merged with an \code{OR} operator into a regular expression pattern
like this: \code{"(one|two|three)"}. See further details in
\code{?parameters::model_parameters}.}
\item{title}{String, will be used as table caption.}
\item{pred.labels}{Character vector with labels of predictor variables.
If not \code{NULL}, \code{pred.labels} will be used in the first
table column with the predictors' names. By default, if \code{auto.label = TRUE}
and \href{https://strengejacke.github.io/sjlabelled/articles/intro_sjlabelled.html}{data is labelled},
\code{\link[sjlabelled]{term_labels}} is called to retrieve the labels
of the coefficients, which will be used as predictor labels. If data is
not labelled, \href{https://easystats.github.io/parameters/reference/format_parameters.html}{format_parameters()}
is used to create pretty labels. If \code{pred.labels = ""} or \code{auto.label = FALSE}, the raw
variable names as used in the model formula are used as predictor
labels. If \code{pred.labels} is a named vector, predictor labels (by
default, the names of the model's coefficients) will be matched with the
names of \code{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'.}
\item{dv.labels}{Character vector with labels of dependent variables of all
fitted models. If \code{dv.labels = ""}, the row with names of dependent
variables is omitted from the table.}
\item{wrap.labels}{Numeric, determines how many chars of the value, variable
or axis labels are displayed in one line and when a line break is inserted.}
\item{bootstrap}{Logical, if \code{TRUE}, returns bootstrapped estimates..}
\item{iterations}{Numeric, number of bootstrap iterations (default is 1000).}
\item{seed}{Numeric, the number of the seed to replicate bootstrapped estimates. If \code{NULL}, uses random seed.}
\item{robust}{Deprecated. Please use \code{vcov.fun} directly to specify
the estimation of the variance-covariance matrix.}
\item{vcov.fun}{Variance-covariance matrix used to compute uncertainty
estimates (e.g., for robust standard errors). This argument accepts a
covariance matrix, a function which returns a covariance matrix, or a
string which identifies the function to be used to compute the covariance
matrix. See \code{\link[parameters:model_parameters]{model_parameters()}}.}
\item{vcov.type}{Deprecated. The \code{type}-argument is now included in
\code{vcov.args}.}
\item{vcov.args}{List of arguments to be passed to the function identified by
the \code{vcov.fun} argument. This function is typically supplied by the
\pkg{sandwich} or \pkg{clubSandwich} packages. Please refer to their
documentation (e.g., \code{?sandwich::vcovHAC}) to see the list of
available arguments.}
\item{string.pred}{Character vector,used as headline for the predictor column.
Default is \code{"Predictors"}.}
\item{string.est}{Character vector, used for the column heading of coefficients.
Default is based on the response scale, e.g. for logistic regression models,
\code{"Odds Ratios"} will be chosen, while for Poisson models it is
\code{"Incidence Rate Ratios"} etc. Default if not specified is \code{"Estimate"}.}
\item{string.std}{Character vector, used for the column heading of standardized beta coefficients. Default is \code{"std. Beta"}.}
\item{string.ci}{Character vector, used for the column heading of confidence interval values. Default is \code{"CI"}.}
\item{string.se}{Character vector, used for the column heading of standard error values. Default is \code{"std. Error"}.}
\item{string.std_se}{Character vector, used for the column heading of standard error of standardized coefficients. Default is \code{"standardized std. Error"}.}
\item{string.std_ci}{Character vector, used for the column heading of confidence intervals of standardized coefficients. Default is \code{"standardized std. Error"}.}
\item{string.p}{Character vector, used for the column heading of p values. Default is \code{"p"}.}
\item{string.std.p}{Character vector, used for the column heading of p values. Default is \code{"std. p"}.}
\item{string.df}{Character vector, used for the column heading of degrees of freedom. Default is \code{"df"}.}
\item{string.stat}{Character vector, used for the test statistic. Default is \code{"Statistic"}.}
\item{string.std.stat}{Character vector, used for the test statistic. Default is \code{"std. Statistic"}.}
\item{string.resp}{Character vector, used for the column heading of of the response level for multinominal or categorical models. Default is \code{"Response"}.}
\item{string.intercept}{Character vector, used as name for the intercept parameter. Default is \code{"(Intercept)"}.}
\item{strings}{Named character vector, as alternative to arguments like \code{string.ci}
or \code{string.p} etc. The name (lhs) must be one of the string-indicator from
the aforementioned arguments, while the value (rhs) is the string that is used
as column heading. E.g., \code{strings = c(ci = "Conf.Int.", se = "std. Err")}
would be equivalent to setting \code{string.ci = "Conf.Int.", string.se = "std. Err"}.}
\item{ci.hyphen}{Character vector, indicating the hyphen for confidence interval range.
May be an HTML entity. See 'Examples'.}
\item{minus.sign}{string, indicating the minus sign for negative numbers.
May be an HTML entity. See 'Examples'.}
\item{collapse.ci}{Logical, if \code{FALSE}, the CI values are shown in
a separate table column.}
\item{collapse.se}{Logical, if \code{FALSE}, the SE values are shown in
a separate table column.}
\item{linebreak}{Logical, if \code{TRUE} and \code{collapse.ci = FALSE} or
\code{collapse.se = FALSE}, inserts a line break between estimate and
CI resp. SE values. If \code{FALSE}, values are printed in the same line
as estimate values.}
\item{col.order}{Character vector, indicating which columns should be printed
and in which order. Column names that are excluded from \code{col.order}
are not shown in the table output. However, column names that are included,
are only shown in the table when the related argument (like \code{show.est}
for \code{"estimate"}) is set to \code{TRUE} or another valid value.
Table columns are printed in the order as they appear in \code{col.order}.}
\item{digits}{Amount of decimals for estimates}
\item{digits.p}{Amount of decimals for p-values}
\item{digits.rsq}{Amount of decimals for r-squared values}
\item{digits.re}{Amount of decimals for random effects part of the summary table.}
\item{emph.p}{Logical, if \code{TRUE}, significant p-values are shown bold faced.}
\item{df.method, p.val}{Method for computing degrees of freedom for p-values,
standard errors and confidence intervals (CI). Only applies to mixed models.
Use \code{df.method = "wald"} for a faster, but less precise computation.
This will use the residual degrees of freedom (as returned by \code{df.residual()})
for linear mixed models, and \code{Inf} degrees if freedom for all other
model families. \code{df.method = "kenward"} (or \code{df.method = "kr"})
uses Kenward-Roger approximation for the degrees of freedom.
\code{df.method = "satterthwaite"} uses Satterthwaite's approximation and
\code{"ml1"} uses a "m-l-1" heuristic see \code{\link[parameters]{degrees_of_freedom}}
for details). Use \code{show.df = TRUE} to show the approximated degrees of freedom
for each coefficient.}
\item{p.style}{Character, indicating if p-values should be printed as
numeric value (\code{"numeric"}), as 'stars' (asterisks) only (\code{"stars"}),
or scientific (\code{"scientific"}). Scientific and numeric style can be
combined with "stars", e.g. \code{"numeric_stars"}}
\item{p.threshold}{Numeric vector of length 3, indicating the treshold for
annotating p-values with asterisks. Only applies if
\code{p.style = "asterisk"}.}
\item{p.adjust}{Character vector, if not \code{NULL}, indicates the method
to adjust p-values. See \code{\link[stats]{p.adjust}} for details.}
\item{case}{Desired target case. Labels will automatically converted into the
specified character case. See \code{snakecase::to_any_case()} for more
details on this argument. By default, if \code{case} is not specified,
it will be set to \code{"parsed"}, unless \code{prefix.labels} is not
\code{"none"}. If \code{prefix.labels} is either \code{"label"} (or
\code{"l"}) or \code{"varname"} (or \code{"v"}) and \code{case} is not
specified, it will be set to \code{NULL} - this is a more convenient
default when prefixing labels.}
\item{auto.label}{Logical, if \code{TRUE} (the default),
and \href{https://strengejacke.github.io/sjlabelled/articles/intro_sjlabelled.html}{data is labelled},
\code{\link[sjlabelled]{term_labels}} is called to retrieve the labels
of the coefficients, which will be used as predictor labels. If data is
not labelled, \href{https://easystats.github.io/parameters/reference/format_parameters.html}{format_parameters()}
is used to create pretty labels. If \code{auto.label = FALSE},
original variable names and value labels (factor levels) are used.}
\item{prefix.labels}{Indicates whether the value labels of categorical variables
should be prefixed, e.g. with the variable name or variable label. See
argument \code{prefix} in \code{\link[sjlabelled]{term_labels}} for
details.}
\item{bpe}{For \strong{Stan}-models (fitted with the \pkg{rstanarm}- or
\pkg{brms}-package), the Bayesian point estimate is, by default, the median
of the posterior distribution. Use \code{bpe} to define other functions to
calculate the Bayesian point estimate. \code{bpe} needs to be a character
naming the specific function, which is passed to the \code{fun}-argument in
\code{\link[sjmisc]{typical_value}}. So, \code{bpe = "mean"} would
calculate the mean value of the posterior distribution.}
\item{CSS}{A \code{\link{list}} with user-defined style-sheet-definitions,
according to the \href{https://www.w3.org/Style/CSS/}{official CSS syntax}.
See 'Details' or \href{https://strengejacke.github.io/sjPlot/articles/table_css.html}{this package-vignette}.}
\item{file}{Destination file, if the output should be saved as file.
If \code{NULL} (default), the output will be saved as temporary file and
opened either in the IDE's viewer pane or the default web browser.}
\item{use.viewer}{Logical, if \code{TRUE}, the HTML table is shown in the IDE's
viewer pane. If \code{FALSE} or no viewer available, the HTML table is
opened in a web browser.}
\item{encoding}{Character vector, indicating the charset encoding used
for variable and value labels. Default is \code{"UTF-8"}. For Windows
Systems, \code{encoding = "Windows-1252"} might be necessary for proper
display of special characters.}
}
\value{
Invisibly returns
\itemize{
\item the web page style sheet (\code{page.style}),
\item the web page content (\code{page.content}),
\item the complete html-output (\code{page.complete}) and
\item the html-table with inline-css for use with knitr (\code{knitr})
}
for further use.
}
\description{
\code{tab_model()} creates HTML tables from regression models.
}
\details{
\subsection{Standardized Estimates}{
Default standardization is done by completely refitting the model on the
standardized data. Hence, this approach is equal to standardizing the
variables before fitting the model, which is particularly recommended for
complex models that include interactions or transformations (e.g., polynomial
or spline terms). When \code{show.std = "std2"}, standardization of estimates
follows \href{http://www.stat.columbia.edu/~gelman/research/published/standardizing7.pdf}{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. For backward compatibility reasons,
\code{show.std} also may be a logical value; if \code{TRUE}, normal standardized
estimates are printed (same effect as \code{show.std = "std"}). Use
\code{show.std = NULL} (default) or \code{show.std = FALSE}, if no standardization
is required.
}
\subsection{How do I use \code{CSS}-argument?}{
With the \code{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 \code{page.style} for details.
Arguments for this list have following syntax:
\enumerate{
\item the class-names with \code{"css."}-prefix as argument name and
\item 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:
\itemize{
\item \code{css.table = 'border:2px solid red;'} for a solid 2-pixel table border in red.
\item \code{css.summary = 'font-weight:bold;'} for a bold fontweight in the summary row.
\item \code{css.lasttablerow = 'border-bottom: 1px dotted blue;'} for a blue dotted border of the last table row.
\item \code{css.colnames = '+color:green'} to add green color formatting to column names.
\item \code{css.arc = 'color:blue;'} for a blue text color each 2nd row.
\item \code{css.caption = '+color:red;'} to add red font-color to the default table caption style.
}
}
}
\note{
The HTML tables can either be saved as file and manually opened (use argument \code{file}) or
they can be saved as temporary files and will be displayed in the RStudio Viewer pane (if working with RStudio)
or opened with the default web browser. Displaying resp. opening a temporary file is the
default behaviour (i.e. \code{file = NULL}).
\cr \cr
Examples are shown in these three vignettes:
\href{https://strengejacke.github.io/sjPlot/articles/tab_model_estimates.html}{Summary of Regression Models as HTML Table},
\href{https://strengejacke.github.io/sjPlot/articles/tab_mixed.html}{Summary of Mixed Models as HTML Table} and
\href{https://strengejacke.github.io/sjPlot/articles/tab_bayes.html}{Summary of Bayesian Models as HTML Table}.
}
|