This functions takes a data frame with model parameters as input and formats certain columns into a more readable layout (like collapsing separate columns for lower and upper confidence interval values). Furthermore, column names are formatted as well. Note that format_table() converts all columns into character vectors!

format_table(
  x,
  pretty_names = TRUE,
  stars = FALSE,
  digits = 2,
  ci_width = "auto",
  ci_brackets = TRUE,
  ci_digits = 2,
  p_digits = 3,
  rope_digits = 2,
  zap_small = FALSE,
  preserve_attributes = FALSE,
  verbose = TRUE,
  ...
)

parameters_table(
  x,
  pretty_names = TRUE,
  stars = FALSE,
  digits = 2,
  ci_width = "auto",
  ci_brackets = TRUE,
  ci_digits = 2,
  p_digits = 3,
  rope_digits = 2,
  zap_small = FALSE,
  preserve_attributes = FALSE,
  verbose = TRUE,
  ...
)

Arguments

x

A data frame of model's parameters, as returned by various functions of the easystats-packages. May also be a result from broom::tidy().

pretty_names

Return "pretty" (i.e. more human readable) parameter names.

stars

Add significance stars (e.g., p < .001***).

digits

Number of decimal places for numeric values (except confidence intervals and p-values).

ci_width

Minimum width of the returned string for confidence intervals. If not NULL and width is larger than the string's length, leading whitespaces are added to the string. If width="auto", width will be set to the length of the longest string.

ci_brackets

Logical, if TRUE (default), CI-values are encompassed in square brackets (else in parentheses).

ci_digits

Number of decimal places for confidence intervals.

p_digits

Number of decimal places for p-values. May also be "scientific" for scientific notation of p-values.

rope_digits

Number of decimal places for the ROPE percentage values.

zap_small

Logical, if TRUE, small values are rounded after digits decimal places. If FALSE, values with more decimal places than digits are printed in scientific notation.

preserve_attributes

Logical, if TRUE, preserves all attributes from the input data frame.

verbose

Toggle messages and warnings.

...

Arguments passed to or from other methods.

Value

A data frame. Note that format_table() converts all columns into character vectors!

See also

Examples

format_table(head(iris), digits = 1)
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          5.1         3.5          1.4         0.2  setosa
#> 2          4.9         3.0          1.4         0.2  setosa
#> 3          4.7         3.2          1.3         0.2  setosa
#> 4          4.6         3.1          1.5         0.2  setosa
#> 5          5.0         3.6          1.4         0.2  setosa
#> 6          5.4         3.9          1.7         0.4  setosa

if (require("parameters")) {
  x <- model_parameters(lm(Sepal.Length ~ Species * Sepal.Width, data = iris))
  as.data.frame(format_table(x))
  as.data.frame(format_table(x, p_digits = "scientific"))
}
#> Loading required package: parameters
#>                            Parameter Coefficient   SE        95% CI t(144)
#> 1                        (Intercept)        2.64 0.57 [ 1.51, 3.77]   4.62
#> 2               Species [versicolor]        0.90 0.80 [-0.68, 2.48]   1.13
#> 3                Species [virginica]        1.27 0.82 [-0.35, 2.88]   1.55
#> 4                        Sepal.Width        0.69 0.17 [ 0.36, 1.02]   4.17
#> 5 Species [versicolor] * Sepal.Width        0.17 0.26 [-0.34, 0.69]   0.67
#> 6  Species [virginica] * Sepal.Width        0.21 0.26 [-0.29, 0.72]   0.83
#>             p
#> 1 8.52612e-06
#> 2 2.61332e-01
#> 3 1.22515e-01
#> 4 5.31104e-05
#> 5 5.02805e-01
#> 6 4.10634e-01
# \donttest{
if (require("rstanarm") && require("parameters")) {
  model <- stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, seed = 123)
  x <- model_parameters(model, ci = c(0.69, 0.89, 0.95))
  as.data.frame(format_table(x))
}
#> Loading required package: rstanarm
#> Loading required package: Rcpp
#> This is rstanarm version 2.21.1
#> - See https://mc-stan.org/rstanarm/articles/priors for changes to default priors!
#> - Default priors may change, so it's safest to specify priors, even if equivalent to the defaults.
#> - For execution on a local, multicore CPU with excess RAM we recommend calling
#>   options(mc.cores = parallel::detectCores())
#> 
#> Attaching package: ‘rstanarm’
#> The following object is masked from ‘package:parameters’:
#> 
#>     compare_models
#> The following object is masked from ‘package:psych’:
#> 
#>     logit
#>           Parameter Median       69% CI       89% CI       95% CI   pd
#> 1       (Intercept)   5.01 [4.94, 5.09] [4.88, 5.11] [4.86, 5.14] 100%
#> 2 Speciesversicolor   0.93 [0.82, 1.03] [0.76, 1.10] [0.74, 1.14] 100%
#> 3  Speciesvirginica   1.58 [1.48, 1.69] [1.41, 1.75] [1.38, 1.78] 100%
#>   % in ROPE  Rhat     ESS                 Prior
#> 1        0% 1.000 3279.00 Normal (5.84 +- 2.07)
#> 2        0% 1.000 3458.00 Normal (0.00 +- 4.38)
#> 3        0% 1.000 3201.00 Normal (0.00 +- 4.38)
# }