diff --git a/DESCRIPTION b/DESCRIPTION
index 950418f45..34e30690f 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
Type: Package
Package: parameters
Title: Processing of Model Parameters
-Version: 0.22.2.18
+Version: 0.22.2.20
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
diff --git a/NEWS.md b/NEWS.md
index 397bb62c8..a898db086 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -34,6 +34,14 @@
* Improved printing for `simulate_parameters()` for models from packages *mclogit*.
+* `print()` for `compare_parameters()` now also puts factor levels into square
+ brackets, like the `print()` method for `model_parameters()`.
+
+## Bug fixes
+
+* Arguments like `digits` etc. were ignored in `model_parameters() for objects
+ from the *marginaleffects* package.
+
# parameters 0.22.2
## New supported models
diff --git a/R/1_model_parameters.R b/R/1_model_parameters.R
index ab2c75968..059d95ee1 100644
--- a/R/1_model_parameters.R
+++ b/R/1_model_parameters.R
@@ -61,7 +61,7 @@
#' [`print_md()`][print_md.parameters_model]. \cr \cr **For developers**, if
#' speed performance is an issue, you can use the (undocumented) `pretty_names`
#' argument, e.g. `model_parameters(..., pretty_names = FALSE)`. This will
-#' skip the formatting of the coefficient names and make `model_parameters()`
+#' skip the formatting of the coefficient names and makes `model_parameters()`
#' faster.
#'
#' @section Standardization of model coefficients:
diff --git a/R/compare_parameters.R b/R/compare_parameters.R
index 2f03e4576..9d4d49e43 100644
--- a/R/compare_parameters.R
+++ b/R/compare_parameters.R
@@ -2,7 +2,7 @@
#' @name compare_parameters
#'
#' @description Compute and extract model parameters of multiple regression
-#' models. See [model_parameters()] for further details.
+#' models. See [`model_parameters()`] for further details.
#'
#' @param ... One or more regression model objects, or objects returned by
#' `model_parameters()`. Regression models may be of different model
@@ -10,7 +10,7 @@
#' If model objects are passed with names or the list has named elements,
#' these names will be used as column names.
#' @param component Model component for which parameters should be shown. See
-#' documentation for related model class in [model_parameters()].
+#' documentation for related model class in [`model_parameters()`].
#' @param column_names Character vector with strings that should be used as
#' column headers. Must be of same length as number of models in `...`.
#' @param ci_method Method for computing degrees of freedom for p-values
@@ -303,11 +303,6 @@ compare_models <- compare_parameters
}
}
}
-
- if (!is.null(x$Parameter)) {
- x$Parameter <- gsub("]", ")", gsub("[", "(", x$Parameter, fixed = TRUE), fixed = TRUE)
- }
-
x
}
diff --git a/R/format.R b/R/format.R
index 857068863..517c02600 100644
--- a/R/format.R
+++ b/R/format.R
@@ -573,13 +573,13 @@ format.parameters_sem <- function(x,
}
# footer: r-squared
- if (isTRUE(show_r2)) {
- footer <- .add_footer_r2(footer, digits, r2, type)
+ if (isTRUE(show_rmse)) {
+ footer <- .add_footer_values(footer, digits, value = rmse, text = "RMSE ", type)
}
# footer: r-squared
- if (isTRUE(show_rmse)) {
- footer <- .add_footer_values(footer, digits, value = rmse, text = "RMSE ", type)
+ if (isTRUE(show_r2)) {
+ footer <- .add_footer_r2(footer, digits, r2, type)
}
# footer: p-adjustment
diff --git a/R/methods_marginaleffects.R b/R/methods_marginaleffects.R
index 803970fa1..8d21acbea 100644
--- a/R/methods_marginaleffects.R
+++ b/R/methods_marginaleffects.R
@@ -45,6 +45,15 @@ model_parameters.marginaleffects <- function(model,
# exponentiate coefficients and SE/CI, if requested
out <- .exponentiate_parameters(out, model = NULL, exponentiate)
+ # add further information as attributes
+ out <- .add_model_parameters_attributes(
+ out,
+ model = model,
+ ci = ci,
+ exponentiate = exponentiate,
+ ...
+ )
+
class(out) <- c("parameters_model", "see_parameters_model", class(out))
out
}
@@ -97,6 +106,15 @@ model_parameters.predictions <- function(model,
# exponentiate coefficients and SE/CI, if requested
out <- .exponentiate_parameters(out, model = NULL, exponentiate)
+ # add further information as attributes
+ out <- .add_model_parameters_attributes(
+ out,
+ model = model,
+ ci = ci,
+ exponentiate = exponentiate,
+ ...
+ )
+
class(out) <- c("parameters_model", "see_parameters_model", class(out))
out
}
diff --git a/R/print.compare_parameters.R b/R/print.compare_parameters.R
index 7d058267f..94aace9bd 100644
--- a/R/print.compare_parameters.R
+++ b/R/print.compare_parameters.R
@@ -42,7 +42,7 @@ print.compare_parameters <- function(x,
zap_small = FALSE,
groups = NULL,
column_width = NULL,
- ci_brackets = c("(", ")"),
+ ci_brackets = c("[", "]"),
select = NULL,
...) {
# save original input
diff --git a/R/print.parameters_model.R b/R/print.parameters_model.R
index e8f6d1206..81933d562 100644
--- a/R/print.parameters_model.R
+++ b/R/print.parameters_model.R
@@ -12,26 +12,33 @@
#' printed. There are three options for this argument:
#'
#' 1. Selecting columns by name or index
-#' \cr
+#'
#' `select` can be a character vector (or numeric index) of column names that
-#' should be printed. There are two pre-defined options for selecting columns:
-#' `select = "minimal"` prints coefficients, confidence intervals and p-values,
-#' while `select = "short"` prints coefficients, standard errors and p-values.
+#' should be printed, where columns are extracted from the data frame returned
+#' by `model_parameters()` and related functions.
+#'
+#' There are two pre-defined options for selecting columns:
+#' `select = "minimal"` prints coefficients, confidence intervals and
+#' p-values, while `select = "short"` prints coefficients, standard errors and
+#' p-values.
#'
#' 2. A string expression with layout pattern
-#' \cr
-#' `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. However, it is possible to create multiple
-#' columns as well. Following tokens are replaced by the related coefficients
-#' or statistics: `{estimate}`, `{se}`, `{ci}` (or `{ci_low}` and `{ci_high}`),
-#' `{p}` and `{stars}`. The token `{ci}` will be replaced by `{ci_low}, {ci_high}`.
-#' Furthermore, a `|` separates values into new cells/columns. If
-#' `format = "html"`, a `
` inserts a line break inside a cell. See
+#'
+#' `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}` 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}"`.
+#'
+#' If `format = "html"`, a `
` inserts a line break inside a cell. See
#' 'Examples'.
#'
#' 3. A string indicating a pre-defined layout
-#' \cr
+#'
#' `select` can be one of the following string values, to create one of the
#' following pre-defined column layouts:
#'
diff --git a/R/print_html.R b/R/print_html.R
index 5c37b831e..616791b5b 100644
--- a/R/print_html.R
+++ b/R/print_html.R
@@ -214,6 +214,12 @@ print_html.compare_parameters <- function(x,
groups = groups
)
+ # replace brackets by parenthesis
+ if (!is.null(ci_brackets) && "Parameter" %in% colnames(formatted_table)) {
+ formatted_table$Parameter <- gsub("[", ci_brackets[1], formatted_table$Parameter, fixed = TRUE)
+ formatted_table$Parameter <- gsub("]", ci_brackets[2], formatted_table$Parameter, fixed = TRUE)
+ }
+
out <- insight::export_table(
formatted_table,
format = "html",
diff --git a/R/print_md.R b/R/print_md.R
index f7bc40e64..877d7dc01 100644
--- a/R/print_md.R
+++ b/R/print_md.R
@@ -176,6 +176,12 @@ print_md.compare_parameters <- function(x,
engine = engine
)
+ # replace brackets by parenthesis
+ if (!is.null(ci_brackets) && "Parameter" %in% colnames(formatted_table)) {
+ formatted_table$Parameter <- gsub("[", ci_brackets[1], formatted_table$Parameter, fixed = TRUE)
+ formatted_table$Parameter <- gsub("]", ci_brackets[2], formatted_table$Parameter, fixed = TRUE)
+ }
+
if (identical(engine, "tt")) {
# retrieve output format - print_md() may be called from print_html()
dots <- list(...)
@@ -285,7 +291,11 @@ print_md.parameters_pca <- print_md.parameters_efa
# Equivalence test ----------------------------
#' @export
-print_md.equivalence_test_lm <- function(x, digits = 2, ci_brackets = c("(", ")"), zap_small = FALSE, ...) {
+print_md.equivalence_test_lm <- function(x,
+ digits = 2,
+ ci_brackets = c("(", ")"),
+ zap_small = FALSE,
+ ...) {
rule <- attributes(x)$rule
rope <- attributes(x)$rope
diff --git a/R/utils_format.R b/R/utils_format.R
index 4b2a58d73..fa0110266 100644
--- a/R/utils_format.R
+++ b/R/utils_format.R
@@ -371,7 +371,7 @@
# check if we have model data, else return parameter table
if (is.null(model_data)) {
- params
+ return(params)
}
# find factors and factor levels and check if we have any factors in the data
@@ -385,7 +385,17 @@
factors <- factors[setdiff(names(factors), remove_contrasts)]
}
if (!length(factors)) {
- params
+ # in case of "on-the-fly" factors, e.g.:
+ # m <- lm(mpg ~ cut(wt, c(0, 2.5, 3, 5)), data = mtcars)
+ # we need to receive the data from the model frame, in order to find factors
+ model_data <- insight::get_data(model, source = "mf", verbose = FALSE)
+ if (!is.null(model_data)) {
+ factors <- .find_factor_levels(model_data, model, model_call = attributes(params)$model_call)
+ }
+ # if we still didn't find anything, quit...
+ if (!length(factors)) {
+ return(params)
+ }
}
# we need some more information about prettified labels etc.
@@ -438,6 +448,19 @@
}
# create a pretty level for the reference category
pretty_level <- paste0(fn_clean, " [", sub(fn, "", reference_level, fixed = TRUE), "]")
+ pretty_level <- gsub("_", " ", pretty_level, fixed = TRUE)
+ # special handling for "cut()"
+ pattern_cut_right <- "(.*)\\((.*),(.*)\\]\\]$"
+ pattern_cut_left <- "(.*)\\[(.*),(.*)\\)\\]$"
+ if (all(grepl(pattern_cut_right, pretty_level))) {
+ lower_bounds <- gsub(pattern_cut_right, "\\2", pretty_level)
+ upper_bounds <- gsub(pattern_cut_right, "\\3", pretty_level)
+ pretty_level <- gsub(pattern_cut_right, paste0("\\1>", as.numeric(lower_bounds), "-", upper_bounds, "]"), pretty_level)
+ } else if (all(grepl(pattern_cut_left, pretty_level))) {
+ lower_bounds <- gsub(pattern_cut_left, "\\2", pretty_level)
+ upper_bounds <- gsub(pattern_cut_left, "\\3", pretty_level)
+ pretty_level <- gsub(pattern_cut_left, paste0("\\1", as.numeric(lower_bounds), "-<", upper_bounds, "]"), pretty_level)
+ }
# insert new pretty level at the correct position in "pretty_names"
pretty_names <- .insert_element_at(
pretty_names,
diff --git a/man/bootstrap_parameters.Rd b/man/bootstrap_parameters.Rd
index 4a3070380..fcecdba27 100644
--- a/man/bootstrap_parameters.Rd
+++ b/man/bootstrap_parameters.Rd
@@ -33,11 +33,9 @@ bootstrap_parameters(model, ...)
\item{ci}{Value or vector of probability of the CI (between 0 and 1)
to be estimated. Default to \code{0.95} (\verb{95\%}).}
-\item{ci_method}{The type of index used for Credible Interval. Can be
-\code{"ETI"} (default, see \code{\link[bayestestR:eti]{eti()}}), \code{"HDI"}
-(see \code{\link[bayestestR:hdi]{hdi()}}), \code{"BCI"} (see
-\code{\link[bayestestR:bci]{bci()}}), \code{"SPI"} (see \code{\link[bayestestR:spi]{spi()}}), or
-\code{"SI"} (see \code{\link[bayestestR:si]{si()}}).}
+\item{ci_method}{The type of index used for Credible Interval. Can be \code{"ETI"}
+(default, see \code{\link[bayestestR:eti]{eti()}}), \code{"HDI"} (see \code{\link[bayestestR:hdi]{hdi()}}), \code{"BCI"} (see \code{\link[bayestestR:bci]{bci()}}),
+\code{"SPI"} (see \code{\link[bayestestR:spi]{spi()}}), or \code{"SI"} (see \code{\link[bayestestR:si]{si()}}).}
\item{test}{The indices to compute. Character (vector) with one or more of
these options: \code{"p-value"} (or \code{"p"}), \code{"p_direction"} (or \code{"pd"}), \code{"rope"},
diff --git a/man/compare_parameters.Rd b/man/compare_parameters.Rd
index 0218c9bb0..cf84f961d 100644
--- a/man/compare_parameters.Rd
+++ b/man/compare_parameters.Rd
@@ -106,41 +106,52 @@ possible adjustment methods are \code{"tukey"}, \code{"scheffe"},
printed. There are three options for this argument:
\enumerate{
\item Selecting columns by name or index
-\cr
+}
+
\code{select} can be a character vector (or numeric index) of column names that
-should be printed. There are two pre-defined options for selecting columns:
-\code{select = "minimal"} prints coefficients, confidence intervals and p-values,
-while \code{select = "short"} prints coefficients, standard errors and p-values.
+should be printed, where columns are extracted from the data frame returned
+by \code{model_parameters()} and related functions.
+
+There are two pre-defined options for selecting columns:
+\code{select = "minimal"} prints coefficients, confidence intervals and
+p-values, while \code{select = "short"} prints coefficients, standard errors and
+p-values.
+\enumerate{
\item A string expression with layout pattern
-\cr
-\code{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. However, it is possible to create multiple
-columns as well. Following tokens are replaced by the related coefficients
-or statistics: \code{{estimate}}, \code{{se}}, \code{{ci}} (or \code{{ci_low}} and \code{{ci_high}}),
-\code{{p}} and \code{{stars}}. The token \code{{ci}} will be replaced by \verb{\{ci_low\}, \{ci_high\}}.
-Furthermore, a \code{|} separates values into new cells/columns. If
-\code{format = "html"}, a \verb{
} inserts a line break inside a cell. See
+}
+
+\code{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: \code{{estimate}}, \code{{se}}, \code{{ci}} (or \code{{ci_low}} and
+\code{{ci_high}}), \code{{p}} and \code{{stars}}. The token \code{{ci}} will be replaced by
+\verb{\{ci_low\}, \{ci_high\}}. Example: \code{select = "{estimate}{stars} ({ci})"}
+
+It is possible to create multiple columns as well. A \code{|} separates values
+into new cells/columns. Example: \code{select = "{estimate} ({ci})|{p}"}.
+
+If \code{format = "html"}, a \verb{
} inserts a line break inside a cell. See
'Examples'.
+\enumerate{
\item A string indicating a pre-defined layout
-\cr
+}
+
\code{select} can be one of the following string values, to create one of the
following pre-defined column layouts:
-\itemize{
-\item \code{"ci"}: Estimates and confidence intervals, no asterisks for p-values.
-This is equivalent to \code{select = "{estimate} ({ci})"}.
-\item \code{"se"}: Estimates and standard errors, no asterisks for p-values. This is
-equivalent to \code{select = "{estimate} ({se})"}.
-\item \code{"ci_p"}: Estimates, confidence intervals and asterisks for p-values. This
-is equivalent to \code{select = "{estimate}{stars} ({ci})"}.
-\item \code{"se_p"}: Estimates, standard errors and asterisks for p-values. This is
-equivalent to \code{select = "{estimate}{stars} ({se})"}..
-\item \code{"ci_p2"}: Estimates, confidence intervals and numeric p-values, in two
-columns. This is equivalent to \code{select = "{estimate} ({ci})|{p}"}.
-\item \code{"se_p2"}: Estimate, standard errors and numeric p-values, in two columns.
-This is equivalent to \code{select = "{estimate} ({se})|{p}"}.
-}
-}
+
+\if{html}{\out{
}}\preformatted{- `"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\}"`.
+}\if{html}{\out{
}}
For \code{model_parameters()}, glue-like syntax is still experimental in the
case of more complex models (like mixed models) and may not return expected
diff --git a/man/display.parameters_model.Rd b/man/display.parameters_model.Rd
index c7ef7f915..66dc3e304 100644
--- a/man/display.parameters_model.Rd
+++ b/man/display.parameters_model.Rd
@@ -83,41 +83,52 @@ in a single table and a \code{Component} column is added to the output.}
printed. There are three options for this argument:
\enumerate{
\item Selecting columns by name or index
-\cr
+}
+
\code{select} can be a character vector (or numeric index) of column names that
-should be printed. There are two pre-defined options for selecting columns:
-\code{select = "minimal"} prints coefficients, confidence intervals and p-values,
-while \code{select = "short"} prints coefficients, standard errors and p-values.
+should be printed, where columns are extracted from the data frame returned
+by \code{model_parameters()} and related functions.
+
+There are two pre-defined options for selecting columns:
+\code{select = "minimal"} prints coefficients, confidence intervals and
+p-values, while \code{select = "short"} prints coefficients, standard errors and
+p-values.
+\enumerate{
\item A string expression with layout pattern
-\cr
-\code{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. However, it is possible to create multiple
-columns as well. Following tokens are replaced by the related coefficients
-or statistics: \code{{estimate}}, \code{{se}}, \code{{ci}} (or \code{{ci_low}} and \code{{ci_high}}),
-\code{{p}} and \code{{stars}}. The token \code{{ci}} will be replaced by \verb{\{ci_low\}, \{ci_high\}}.
-Furthermore, a \code{|} separates values into new cells/columns. If
-\code{format = "html"}, a \verb{
} inserts a line break inside a cell. See
+}
+
+\code{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: \code{{estimate}}, \code{{se}}, \code{{ci}} (or \code{{ci_low}} and
+\code{{ci_high}}), \code{{p}} and \code{{stars}}. The token \code{{ci}} will be replaced by
+\verb{\{ci_low\}, \{ci_high\}}. Example: \code{select = "{estimate}{stars} ({ci})"}
+
+It is possible to create multiple columns as well. A \code{|} separates values
+into new cells/columns. Example: \code{select = "{estimate} ({ci})|{p}"}.
+
+If \code{format = "html"}, a \verb{
} inserts a line break inside a cell. See
'Examples'.
+\enumerate{
\item A string indicating a pre-defined layout
-\cr
+}
+
\code{select} can be one of the following string values, to create one of the
following pre-defined column layouts:
-\itemize{
-\item \code{"ci"}: Estimates and confidence intervals, no asterisks for p-values.
-This is equivalent to \code{select = "{estimate} ({ci})"}.
-\item \code{"se"}: Estimates and standard errors, no asterisks for p-values. This is
-equivalent to \code{select = "{estimate} ({se})"}.
-\item \code{"ci_p"}: Estimates, confidence intervals and asterisks for p-values. This
-is equivalent to \code{select = "{estimate}{stars} ({ci})"}.
-\item \code{"se_p"}: Estimates, standard errors and asterisks for p-values. This is
-equivalent to \code{select = "{estimate}{stars} ({se})"}..
-\item \code{"ci_p2"}: Estimates, confidence intervals and numeric p-values, in two
-columns. This is equivalent to \code{select = "{estimate} ({ci})|{p}"}.
-\item \code{"se_p2"}: Estimate, standard errors and numeric p-values, in two columns.
-This is equivalent to \code{select = "{estimate} ({se})|{p}"}.
-}
-}
+
+\if{html}{\out{}}\preformatted{- `"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\}"`.
+}\if{html}{\out{
}}
For \code{model_parameters()}, glue-like syntax is still experimental in the
case of more complex models (like mixed models) and may not return expected
diff --git a/man/model_parameters.BFBayesFactor.Rd b/man/model_parameters.BFBayesFactor.Rd
index 9b67ccb4f..227174bf1 100644
--- a/man/model_parameters.BFBayesFactor.Rd
+++ b/man/model_parameters.BFBayesFactor.Rd
@@ -35,19 +35,17 @@ Dispersion is not available for \code{"MAP"} or \code{"mode"} centrality indices
\item{ci}{Value or vector of probability of the CI (between 0 and 1)
to be estimated. Default to \code{0.95} (\verb{95\%}).}
-\item{ci_method}{The type of index used for Credible Interval. Can be
-\code{"ETI"} (default, see \code{\link[bayestestR:eti]{eti()}}), \code{"HDI"}
-(see \code{\link[bayestestR:hdi]{hdi()}}), \code{"BCI"} (see
-\code{\link[bayestestR:bci]{bci()}}), \code{"SPI"} (see \code{\link[bayestestR:spi]{spi()}}), or
-\code{"SI"} (see \code{\link[bayestestR:si]{si()}}).}
+\item{ci_method}{The type of index used for Credible Interval. Can be \code{"ETI"}
+(default, see \code{\link[bayestestR:eti]{eti()}}), \code{"HDI"} (see \code{\link[bayestestR:hdi]{hdi()}}), \code{"BCI"} (see \code{\link[bayestestR:bci]{bci()}}),
+\code{"SPI"} (see \code{\link[bayestestR:spi]{spi()}}), or \code{"SI"} (see \code{\link[bayestestR:si]{si()}}).}
\item{test}{The indices of effect existence to compute. Character (vector) or
list with one or more of these options: \code{"p_direction"} (or \code{"pd"}),
\code{"rope"}, \code{"p_map"}, \code{"equivalence_test"} (or \code{"equitest"}),
-\code{"bayesfactor"} (or \code{"bf"}) or \code{"all"} to compute all tests.
-For each "test", the corresponding \pkg{bayestestR} function is called
-(e.g. \code{\link[bayestestR:rope]{rope()}} or \code{\link[bayestestR:p_direction]{p_direction()}}) and its results
-included in the summary output.}
+\code{"bayesfactor"} (or \code{"bf"}) or \code{"all"} to compute all tests. For each
+"test", the corresponding \pkg{bayestestR} function is called (e.g.
+\code{\link[bayestestR:rope]{rope()}} or \code{\link[bayestestR:p_direction]{p_direction()}}) and its results included in the summary
+output.}
\item{rope_range}{ROPE's lower and higher bounds. Should be a vector of two
values (e.g., \code{c(-0.1, 0.1)}), \code{"default"} or a list of numeric vectors of
diff --git a/man/model_parameters.Rd b/man/model_parameters.Rd
index c3e5dc2f1..c75d74853 100644
--- a/man/model_parameters.Rd
+++ b/man/model_parameters.Rd
@@ -72,7 +72,7 @@ method for use inside rmarkdown files,
\code{\link[=print_md.parameters_model]{print_md()}}. \cr \cr \strong{For developers}, if
speed performance is an issue, you can use the (undocumented) \code{pretty_names}
argument, e.g. \code{model_parameters(..., pretty_names = FALSE)}. This will
-skip the formatting of the coefficient names and make \code{model_parameters()}
+skip the formatting of the coefficient names and makes \code{model_parameters()}
faster.
}
\section{Standardization of model coefficients}{
diff --git a/man/model_parameters.befa.Rd b/man/model_parameters.befa.Rd
index dc991711d..925cee7bc 100644
--- a/man/model_parameters.befa.Rd
+++ b/man/model_parameters.befa.Rd
@@ -33,19 +33,17 @@ Dispersion is not available for \code{"MAP"} or \code{"mode"} centrality indices
\item{ci}{Value or vector of probability of the CI (between 0 and 1)
to be estimated. Default to \code{0.95} (\verb{95\%}).}
-\item{ci_method}{The type of index used for Credible Interval. Can be
-\code{"ETI"} (default, see \code{\link[bayestestR:eti]{eti()}}), \code{"HDI"}
-(see \code{\link[bayestestR:hdi]{hdi()}}), \code{"BCI"} (see
-\code{\link[bayestestR:bci]{bci()}}), \code{"SPI"} (see \code{\link[bayestestR:spi]{spi()}}), or
-\code{"SI"} (see \code{\link[bayestestR:si]{si()}}).}
+\item{ci_method}{The type of index used for Credible Interval. Can be \code{"ETI"}
+(default, see \code{\link[bayestestR:eti]{eti()}}), \code{"HDI"} (see \code{\link[bayestestR:hdi]{hdi()}}), \code{"BCI"} (see \code{\link[bayestestR:bci]{bci()}}),
+\code{"SPI"} (see \code{\link[bayestestR:spi]{spi()}}), or \code{"SI"} (see \code{\link[bayestestR:si]{si()}}).}
\item{test}{The indices of effect existence to compute. Character (vector) or
list with one or more of these options: \code{"p_direction"} (or \code{"pd"}),
\code{"rope"}, \code{"p_map"}, \code{"equivalence_test"} (or \code{"equitest"}),
-\code{"bayesfactor"} (or \code{"bf"}) or \code{"all"} to compute all tests.
-For each "test", the corresponding \pkg{bayestestR} function is called
-(e.g. \code{\link[bayestestR:rope]{rope()}} or \code{\link[bayestestR:p_direction]{p_direction()}}) and its results
-included in the summary output.}
+\code{"bayesfactor"} (or \code{"bf"}) or \code{"all"} to compute all tests. For each
+"test", the corresponding \pkg{bayestestR} function is called (e.g.
+\code{\link[bayestestR:rope]{rope()}} or \code{\link[bayestestR:p_direction]{p_direction()}}) and its results included in the summary
+output.}
\item{verbose}{Toggle warnings.}
diff --git a/man/model_parameters.stanreg.Rd b/man/model_parameters.stanreg.Rd
index 57095a54b..af4303bed 100644
--- a/man/model_parameters.stanreg.Rd
+++ b/man/model_parameters.stanreg.Rd
@@ -126,10 +126,10 @@ cases \code{"wald"} is used then.}
\item{test}{The indices of effect existence to compute. Character (vector) or
list with one or more of these options: \code{"p_direction"} (or \code{"pd"}),
\code{"rope"}, \code{"p_map"}, \code{"equivalence_test"} (or \code{"equitest"}),
-\code{"bayesfactor"} (or \code{"bf"}) or \code{"all"} to compute all tests.
-For each "test", the corresponding \pkg{bayestestR} function is called
-(e.g. \code{\link[bayestestR:rope]{rope()}} or \code{\link[bayestestR:p_direction]{p_direction()}}) and its results
-included in the summary output.}
+\code{"bayesfactor"} (or \code{"bf"}) or \code{"all"} to compute all tests. For each
+"test", the corresponding \pkg{bayestestR} function is called (e.g.
+\code{\link[bayestestR:rope]{rope()}} or \code{\link[bayestestR:p_direction]{p_direction()}}) and its results included in the summary
+output.}
\item{rope_range}{ROPE's lower and higher bounds. Should be a vector of two
values (e.g., \code{c(-0.1, 0.1)}), \code{"default"} or a list of numeric vectors of
diff --git a/man/print.compare_parameters.Rd b/man/print.compare_parameters.Rd
index d74c26307..a7e5798ca 100644
--- a/man/print.compare_parameters.Rd
+++ b/man/print.compare_parameters.Rd
@@ -36,7 +36,7 @@
zap_small = FALSE,
groups = NULL,
column_width = NULL,
- ci_brackets = c("(", ")"),
+ ci_brackets = c("[", "]"),
select = NULL,
...
)
@@ -89,41 +89,52 @@ in a single table and a \code{Component} column is added to the output.}
printed. There are three options for this argument:
\enumerate{
\item Selecting columns by name or index
-\cr
+}
+
\code{select} can be a character vector (or numeric index) of column names that
-should be printed. There are two pre-defined options for selecting columns:
-\code{select = "minimal"} prints coefficients, confidence intervals and p-values,
-while \code{select = "short"} prints coefficients, standard errors and p-values.
+should be printed, where columns are extracted from the data frame returned
+by \code{model_parameters()} and related functions.
+
+There are two pre-defined options for selecting columns:
+\code{select = "minimal"} prints coefficients, confidence intervals and
+p-values, while \code{select = "short"} prints coefficients, standard errors and
+p-values.
+\enumerate{
\item A string expression with layout pattern
-\cr
-\code{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. However, it is possible to create multiple
-columns as well. Following tokens are replaced by the related coefficients
-or statistics: \code{{estimate}}, \code{{se}}, \code{{ci}} (or \code{{ci_low}} and \code{{ci_high}}),
-\code{{p}} and \code{{stars}}. The token \code{{ci}} will be replaced by \verb{\{ci_low\}, \{ci_high\}}.
-Furthermore, a \code{|} separates values into new cells/columns. If
-\code{format = "html"}, a \verb{
} inserts a line break inside a cell. See
+}
+
+\code{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: \code{{estimate}}, \code{{se}}, \code{{ci}} (or \code{{ci_low}} and
+\code{{ci_high}}), \code{{p}} and \code{{stars}}. The token \code{{ci}} will be replaced by
+\verb{\{ci_low\}, \{ci_high\}}. Example: \code{select = "{estimate}{stars} ({ci})"}
+
+It is possible to create multiple columns as well. A \code{|} separates values
+into new cells/columns. Example: \code{select = "{estimate} ({ci})|{p}"}.
+
+If \code{format = "html"}, a \verb{
} inserts a line break inside a cell. See
'Examples'.
+\enumerate{
\item A string indicating a pre-defined layout
-\cr
+}
+
\code{select} can be one of the following string values, to create one of the
following pre-defined column layouts:
-\itemize{
-\item \code{"ci"}: Estimates and confidence intervals, no asterisks for p-values.
-This is equivalent to \code{select = "{estimate} ({ci})"}.
-\item \code{"se"}: Estimates and standard errors, no asterisks for p-values. This is
-equivalent to \code{select = "{estimate} ({se})"}.
-\item \code{"ci_p"}: Estimates, confidence intervals and asterisks for p-values. This
-is equivalent to \code{select = "{estimate}{stars} ({ci})"}.
-\item \code{"se_p"}: Estimates, standard errors and asterisks for p-values. This is
-equivalent to \code{select = "{estimate}{stars} ({se})"}..
-\item \code{"ci_p2"}: Estimates, confidence intervals and numeric p-values, in two
-columns. This is equivalent to \code{select = "{estimate} ({ci})|{p}"}.
-\item \code{"se_p2"}: Estimate, standard errors and numeric p-values, in two columns.
-This is equivalent to \code{select = "{estimate} ({se})|{p}"}.
-}
-}
+
+\if{html}{\out{}}\preformatted{- `"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\}"`.
+}\if{html}{\out{
}}
For \code{model_parameters()}, glue-like syntax is still experimental in the
case of more complex models (like mixed models) and may not return expected
diff --git a/man/print.parameters_model.Rd b/man/print.parameters_model.Rd
index d3038109c..6cffcda05 100644
--- a/man/print.parameters_model.Rd
+++ b/man/print.parameters_model.Rd
@@ -116,41 +116,52 @@ in a single table and a \code{Component} column is added to the output.}
printed. There are three options for this argument:
\enumerate{
\item Selecting columns by name or index
-\cr
+}
+
\code{select} can be a character vector (or numeric index) of column names that
-should be printed. There are two pre-defined options for selecting columns:
-\code{select = "minimal"} prints coefficients, confidence intervals and p-values,
-while \code{select = "short"} prints coefficients, standard errors and p-values.
+should be printed, where columns are extracted from the data frame returned
+by \code{model_parameters()} and related functions.
+
+There are two pre-defined options for selecting columns:
+\code{select = "minimal"} prints coefficients, confidence intervals and
+p-values, while \code{select = "short"} prints coefficients, standard errors and
+p-values.
+\enumerate{
\item A string expression with layout pattern
-\cr
-\code{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. However, it is possible to create multiple
-columns as well. Following tokens are replaced by the related coefficients
-or statistics: \code{{estimate}}, \code{{se}}, \code{{ci}} (or \code{{ci_low}} and \code{{ci_high}}),
-\code{{p}} and \code{{stars}}. The token \code{{ci}} will be replaced by \verb{\{ci_low\}, \{ci_high\}}.
-Furthermore, a \code{|} separates values into new cells/columns. If
-\code{format = "html"}, a \verb{
} inserts a line break inside a cell. See
+}
+
+\code{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: \code{{estimate}}, \code{{se}}, \code{{ci}} (or \code{{ci_low}} and
+\code{{ci_high}}), \code{{p}} and \code{{stars}}. The token \code{{ci}} will be replaced by
+\verb{\{ci_low\}, \{ci_high\}}. Example: \code{select = "{estimate}{stars} ({ci})"}
+
+It is possible to create multiple columns as well. A \code{|} separates values
+into new cells/columns. Example: \code{select = "{estimate} ({ci})|{p}"}.
+
+If \code{format = "html"}, a \verb{
} inserts a line break inside a cell. See
'Examples'.
+\enumerate{
\item A string indicating a pre-defined layout
-\cr
+}
+
\code{select} can be one of the following string values, to create one of the
following pre-defined column layouts:
-\itemize{
-\item \code{"ci"}: Estimates and confidence intervals, no asterisks for p-values.
-This is equivalent to \code{select = "{estimate} ({ci})"}.
-\item \code{"se"}: Estimates and standard errors, no asterisks for p-values. This is
-equivalent to \code{select = "{estimate} ({se})"}.
-\item \code{"ci_p"}: Estimates, confidence intervals and asterisks for p-values. This
-is equivalent to \code{select = "{estimate}{stars} ({ci})"}.
-\item \code{"se_p"}: Estimates, standard errors and asterisks for p-values. This is
-equivalent to \code{select = "{estimate}{stars} ({se})"}..
-\item \code{"ci_p2"}: Estimates, confidence intervals and numeric p-values, in two
-columns. This is equivalent to \code{select = "{estimate} ({ci})|{p}"}.
-\item \code{"se_p2"}: Estimate, standard errors and numeric p-values, in two columns.
-This is equivalent to \code{select = "{estimate} ({se})|{p}"}.
-}
-}
+
+\if{html}{\out{}}\preformatted{- `"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\}"`.
+}\if{html}{\out{
}}
For \code{model_parameters()}, glue-like syntax is still experimental in the
case of more complex models (like mixed models) and may not return expected
diff --git a/man/simulate_parameters.Rd b/man/simulate_parameters.Rd
index a3a68d909..0f1c4613b 100644
--- a/man/simulate_parameters.Rd
+++ b/man/simulate_parameters.Rd
@@ -41,19 +41,17 @@ simulate_parameters(model, ...)
\item{ci}{Value or vector of probability of the CI (between 0 and 1)
to be estimated. Default to \code{0.95} (\verb{95\%}).}
-\item{ci_method}{The type of index used for Credible Interval. Can be
-\code{"ETI"} (default, see \code{\link[bayestestR:eti]{eti()}}), \code{"HDI"}
-(see \code{\link[bayestestR:hdi]{hdi()}}), \code{"BCI"} (see
-\code{\link[bayestestR:bci]{bci()}}), \code{"SPI"} (see \code{\link[bayestestR:spi]{spi()}}), or
-\code{"SI"} (see \code{\link[bayestestR:si]{si()}}).}
+\item{ci_method}{The type of index used for Credible Interval. Can be \code{"ETI"}
+(default, see \code{\link[bayestestR:eti]{eti()}}), \code{"HDI"} (see \code{\link[bayestestR:hdi]{hdi()}}), \code{"BCI"} (see \code{\link[bayestestR:bci]{bci()}}),
+\code{"SPI"} (see \code{\link[bayestestR:spi]{spi()}}), or \code{"SI"} (see \code{\link[bayestestR:si]{si()}}).}
\item{test}{The indices of effect existence to compute. Character (vector) or
list with one or more of these options: \code{"p_direction"} (or \code{"pd"}),
\code{"rope"}, \code{"p_map"}, \code{"equivalence_test"} (or \code{"equitest"}),
-\code{"bayesfactor"} (or \code{"bf"}) or \code{"all"} to compute all tests.
-For each "test", the corresponding \pkg{bayestestR} function is called
-(e.g. \code{\link[bayestestR:rope]{rope()}} or \code{\link[bayestestR:p_direction]{p_direction()}}) and its results
-included in the summary output.}
+\code{"bayesfactor"} (or \code{"bf"}) or \code{"all"} to compute all tests. For each
+"test", the corresponding \pkg{bayestestR} function is called (e.g.
+\code{\link[bayestestR:rope]{rope()}} or \code{\link[bayestestR:p_direction]{p_direction()}}) and its results included in the summary
+output.}
\item{...}{Arguments passed to \code{\link[insight:get_varcov]{insight::get_varcov()}}, e.g. to allow simulated
draws to be based on heteroscedasticity consistent variance covariance matrices.}
diff --git a/tests/testthat/_snaps/compare_parameters.md b/tests/testthat/_snaps/compare_parameters.md
index 2e807d8ab..c2e2d8d9d 100644
--- a/tests/testthat/_snaps/compare_parameters.md
+++ b/tests/testthat/_snaps/compare_parameters.md
@@ -21,7 +21,7 @@
--------------------------------------------------------------------------------
(Intercept) | 0.91 ( 0.75, 1.07) | 0.68 (-0.54, 1.91) | 1.41 ( 1.06, 1.75)
child | -1.23 (-1.39, -1.08) | -1.67 (-1.84, -1.51) | -0.53 (-0.77, -0.29)
- camper (1) | 1.05 ( 0.88, 1.23) | 0.94 ( 0.77, 1.12) | 0.58 ( 0.39, 0.78)
+ camper [1] | 1.05 ( 0.88, 1.23) | 0.94 ( 0.77, 1.12) | 0.58 ( 0.39, 0.78)
zg | | | 0.13 ( 0.05, 0.21)
# Fixed Effects (Zero-Inflation Component)
@@ -89,13 +89,13 @@
+-------------------------+-----------------------+--------+----------------------+--------+
| Days | 10.44 (8.84, 12.03) | <0.001 | 11.23 (7.87, 14.60) | <0.001 |
+-------------------------+-----------------------+--------+----------------------+--------+
- | grp (2) | -4.31 (-15.95, 7.32) | 0.465 | 0.32 (-22.56, 23.20) | 0.978 |
+ | grp [2] | -4.31 (-15.95, 7.32) | 0.465 | 0.32 (-22.56, 23.20) | 0.978 |
+-------------------------+-----------------------+--------+----------------------+--------+
- | grp (3) | -1.31 (-13.47, 10.84) | 0.831 | 3.77 (-19.72, 27.26) | 0.752 |
+ | grp [3] | -1.31 (-13.47, 10.84) | 0.831 | 3.77 (-19.72, 27.26) | 0.752 |
+-------------------------+-----------------------+--------+----------------------+--------+
- | Days * grp (2) | | | -1.01 (-5.35, 3.32) | 0.645 |
+ | Days * grp [2] | | | -1.01 (-5.35, 3.32) | 0.645 |
+-------------------------+-----------------------+--------+----------------------+--------+
- | Days * grp (3) | | | -1.11 (-5.53, 3.31) | 0.621 |
+ | Days * grp [3] | | | -1.11 (-5.53, 3.31) | 0.621 |
+-------------------------+-----------------------+--------+----------------------+--------+
| Random Effects |
+-------------------------+-----------------------+--------+----------------------+--------+
diff --git a/tests/testthat/_snaps/marginaleffects.md b/tests/testthat/_snaps/marginaleffects.md
new file mode 100644
index 000000000..816061db9
--- /dev/null
+++ b/tests/testthat/_snaps/marginaleffects.md
@@ -0,0 +1,11 @@
+# digits and ci_digits for marginaleffects
+
+ Code
+ out
+ Output
+ # Fixed Effects
+
+ Parameter | Coefficient | SE | Statistic | p | S | 95% CI
+ --------------------------------------------------------------------------
+ 10*wt = 0 | -53.4 | 5.6 | -9.6 | < .001 | 69.5 | [-64.4, -42.5]
+
diff --git a/tests/testthat/_snaps/model_parameters.fixest.md b/tests/testthat/_snaps/model_parameters.fixest.md
index c095a3fe0..dacb2944e 100644
--- a/tests/testthat/_snaps/model_parameters.fixest.md
+++ b/tests/testthat/_snaps/model_parameters.fixest.md
@@ -12,6 +12,6 @@
Model: QoL ~ time + phq4 (564 Observations)
Sigma: 12.365 (df = 561)
- r2: 0.743; ar2: 0.613; wr2: 0.180; war2: 0.175
RMSE : 10.069
+ r2: 0.743; ar2: 0.613; wr2: 0.180; war2: 0.175
diff --git a/tests/testthat/_snaps/model_parameters.glm.md b/tests/testthat/_snaps/model_parameters.glm.md
index 716d9eeb0..7788aa7bf 100644
--- a/tests/testthat/_snaps/model_parameters.glm.md
+++ b/tests/testthat/_snaps/model_parameters.glm.md
@@ -10,8 +10,8 @@
Model: mpg ~ wt (32 Observations)
Sigma: 3.046 (df = 30)
- R2: 0.753; adjusted R2: 0.745
RMSE : 2.949
+ R2: 0.753; adjusted R2: 0.745
---
diff --git a/tests/testthat/_snaps/model_parameters.mixed.md b/tests/testthat/_snaps/model_parameters.mixed.md
index c89fefb71..838291492 100644
--- a/tests/testthat/_snaps/model_parameters.mixed.md
+++ b/tests/testthat/_snaps/model_parameters.mixed.md
@@ -63,8 +63,8 @@
Model: wt ~ cyl (32 Observations)
Sigma: 0.594 (df = 28)
- Conditional R2: 0.628; Marginal R2: 0.550
RMSE : 0.564
+ Conditional R2: 0.628; Marginal R2: 0.550
Message
Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
diff --git a/tests/testthat/_snaps/printing.md b/tests/testthat/_snaps/printing.md
index 750751645..1b086c924 100644
--- a/tests/testthat/_snaps/printing.md
+++ b/tests/testthat/_snaps/printing.md
@@ -93,8 +93,8 @@
Model: Sepal.Length ~ Species * Petal.Length (150 Observations)
Sigma: 0.336 (df = 144)
- R2: 0.840; adjusted R2: 0.835
RMSE : 0.330
+ R2: 0.840; adjusted R2: 0.835
Message
Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
diff --git a/tests/testthat/_snaps/printing2.md b/tests/testthat/_snaps/printing2.md
index 61eb8cce4..088c53ee8 100644
--- a/tests/testthat/_snaps/printing2.md
+++ b/tests/testthat/_snaps/printing2.md
@@ -6,11 +6,11 @@
Parameter | lm1 | lm2 | lm3
-----------------------------------------------------------------------------------------------------
(Intercept) | 5.01 (4.86, 5.15) | 3.68 ( 3.47, 3.89) | 4.21 ( 3.41, 5.02)
- Species (versicolor) | 0.93 (0.73, 1.13) | -1.60 (-1.98, -1.22) | -1.81 (-2.99, -0.62)
- Species (virginica) | 1.58 (1.38, 1.79) | -2.12 (-2.66, -1.58) | -3.15 (-4.41, -1.90)
+ Species [versicolor] | 0.93 (0.73, 1.13) | -1.60 (-1.98, -1.22) | -1.81 (-2.99, -0.62)
+ Species [virginica] | 1.58 (1.38, 1.79) | -2.12 (-2.66, -1.58) | -3.15 (-4.41, -1.90)
Petal Length | | 0.90 ( 0.78, 1.03) | 0.54 ( 0.00, 1.09)
- Species (versicolor) * Petal Length | | | 0.29 (-0.30, 0.87)
- Species (virginica) * Petal Length | | | 0.45 (-0.12, 1.03)
+ Species [versicolor] * Petal Length | | | 0.29 (-0.30, 0.87)
+ Species [virginica] * Petal Length | | | 0.45 (-0.12, 1.03)
-----------------------------------------------------------------------------------------------------
Observations | 150 | 150 | 150
@@ -22,11 +22,11 @@
Parameter | lm1 | lm2 | lm3
----------------------------------------------------------------------------------------
(Intercept) | 5.01*** (0.07) | 3.68*** (0.11) | 4.21*** (0.41)
- Species (versicolor) | 0.93*** (0.10) | -1.60*** (0.19) | -1.81 ** (0.60)
- Species (virginica) | 1.58*** (0.10) | -2.12*** (0.27) | -3.15*** (0.63)
+ Species [versicolor] | 0.93*** (0.10) | -1.60*** (0.19) | -1.81 ** (0.60)
+ Species [virginica] | 1.58*** (0.10) | -2.12*** (0.27) | -3.15*** (0.63)
Petal Length | | 0.90*** (0.06) | 0.54 (0.28)
- Species (versicolor) * Petal Length | | | 0.29 (0.30)
- Species (virginica) * Petal Length | | | 0.45 (0.29)
+ Species [versicolor] * Petal Length | | | 0.29 (0.30)
+ Species [virginica] * Petal Length | | | 0.45 (0.29)
----------------------------------------------------------------------------------------
Observations | 150 | 150 | 150
@@ -38,11 +38,11 @@
Parameter | lm1 | lm2 | lm3
----------------------------------------------------------------------------------------
(Intercept) | 5.01*** (0.07) | 3.68*** (0.11) | 4.21*** (0.41)
- Species (versicolor) | 0.93*** (0.10) | -1.60*** (0.19) | -1.81 ** (0.60)
- Species (virginica) | 1.58*** (0.10) | -2.12*** (0.27) | -3.15*** (0.63)
+ Species [versicolor] | 0.93*** (0.10) | -1.60*** (0.19) | -1.81 ** (0.60)
+ Species [virginica] | 1.58*** (0.10) | -2.12*** (0.27) | -3.15*** (0.63)
Petal Length | | 0.90*** (0.06) | 0.54 (0.28)
- Species (versicolor) * Petal Length | | | 0.29 (0.30)
- Species (virginica) * Petal Length | | | 0.45 (0.29)
+ Species [versicolor] * Petal Length | | | 0.29 (0.30)
+ Species [virginica] * Petal Length | | | 0.45 (0.29)
----------------------------------------------------------------------------------------
Observations | 150 | 150 | 150
@@ -54,11 +54,11 @@
Parameter | lm1 | lm2 | lm3
-----------------------------------------------------------------------------------------------------------------------------------------
(Intercept) | 5.01 (4.86, 5.15), p<0.001*** | 3.68 ( 3.47, 3.89), p<0.001*** | 4.21 ( 3.41, 5.02), p<0.001***
- Species (versicolor) | 0.93 (0.73, 1.13), p<0.001*** | -1.60 (-1.98, -1.22), p<0.001*** | -1.81 (-2.99, -0.62), p=0.003 **
- Species (virginica) | 1.58 (1.38, 1.79), p<0.001*** | -2.12 (-2.66, -1.58), p<0.001*** | -3.15 (-4.41, -1.90), p<0.001***
+ Species [versicolor] | 0.93 (0.73, 1.13), p<0.001*** | -1.60 (-1.98, -1.22), p<0.001*** | -1.81 (-2.99, -0.62), p=0.003 **
+ Species [virginica] | 1.58 (1.38, 1.79), p<0.001*** | -2.12 (-2.66, -1.58), p<0.001*** | -3.15 (-4.41, -1.90), p<0.001***
Petal Length | | 0.90 ( 0.78, 1.03), p<0.001*** | 0.54 ( 0.00, 1.09), p=0.052
- Species (versicolor) * Petal Length | | | 0.29 (-0.30, 0.87), p=0.334
- Species (virginica) * Petal Length | | | 0.45 (-0.12, 1.03), p=0.120
+ Species [versicolor] * Petal Length | | | 0.29 (-0.30, 0.87), p=0.334
+ Species [virginica] * Petal Length | | | 0.45 (-0.12, 1.03), p=0.120
-----------------------------------------------------------------------------------------------------------------------------------------
Observations | 150 | 150 | 150
@@ -70,30 +70,30 @@
Parameter | Estimate (SE) (lm1) | p (lm1) | Estimate (SE) (lm2) | p (lm2) | Estimate (SE) (lm3) | p (lm3)
-----------------------------------------------------------------------------------------------------------------------------------
(Intercept) | 5.01 (0.07) | <0.001 | 3.68 (0.11) | <0.001 | 4.21 (0.41) | <0.001
- Species (versicolor) | 0.93 (0.10) | <0.001 | -1.60 (0.19) | <0.001 | -1.81 (0.60) | 0.003
- Species (virginica) | 1.58 (0.10) | <0.001 | -2.12 (0.27) | <0.001 | -3.15 (0.63) | <0.001
+ Species [versicolor] | 0.93 (0.10) | <0.001 | -1.60 (0.19) | <0.001 | -1.81 (0.60) | 0.003
+ Species [virginica] | 1.58 (0.10) | <0.001 | -2.12 (0.27) | <0.001 | -3.15 (0.63) | <0.001
Petal Length | | | 0.90 (0.06) | <0.001 | 0.54 (0.28) | 0.052
- Species (versicolor) * Petal Length | | | | | 0.29 (0.30) | 0.334
- Species (virginica) * Petal Length | | | | | 0.45 (0.29) | 0.120
+ Species [versicolor] * Petal Length | | | | | 0.29 (0.30) | 0.334
+ Species [virginica] * Petal Length | | | | | 0.45 (0.29) | 0.120
-----------------------------------------------------------------------------------------------------------------------------------
Observations | 150 | | 150 | | 150 |
---
Code
- print(out, groups = list(Species = c("Species (versicolor)",
- "Species (virginica)"), Interactions = c(
- "Species (versicolor) * Petal Length", "Species (virginica) * Petal Length"),
+ print(out, groups = list(Species = c("Species [versicolor]",
+ "Species [virginica]"), Interactions = c(
+ "Species [versicolor] * Petal Length", "Species [virginica] * Petal Length"),
Controls = "Petal Length"))
Output
Parameter | lm1 | lm2
-----------------------------------------------------------------------------------
Species | |
- Species (versicolor) | -1.60 (-1.98, -1.22) | -1.69 (-2.80, -0.57)
- Species (virginica) | -2.12 (-2.66, -1.58) | -1.19 (-2.37, -0.01)
+ Species [versicolor] | -1.60 (-1.98, -1.22) | -1.69 (-2.80, -0.57)
+ Species [virginica] | -2.12 (-2.66, -1.58) | -1.19 (-2.37, -0.01)
Interactions | |
- Species (versicolor) * Petal Length | | -0.01 (-0.56, 0.53)
- Species (virginica) * Petal Length | | -0.15 (-0.69, 0.39)
+ Species [versicolor] * Petal Length | | -0.01 (-0.56, 0.53)
+ Species [virginica] * Petal Length | | -0.15 (-0.69, 0.39)
Controls | |
Petal Length | 0.90 ( 0.78, 1.03) | 0.39 (-0.13, 0.90)
-----------------------------------------------------------------------------------
@@ -102,19 +102,19 @@
---
Code
- print(out, groups = list(Species = c("Species (versicolor)",
- "Species (virginica)"), Interactions = c(
- "Species (versicolor) * Petal Length", "Species (virginica) * Petal Length"),
+ print(out, groups = list(Species = c("Species [versicolor]",
+ "Species [virginica]"), Interactions = c(
+ "Species [versicolor] * Petal Length", "Species [virginica] * Petal Length"),
Controls = "Petal Length"), select = "{estimate}{stars}")
Output
Parameter | lm1 | lm2
----------------------------------------------------------
Species | |
- Species (versicolor) | -1.60*** | -1.69**
- Species (virginica) | -2.12*** | -1.19 *
+ Species [versicolor] | -1.60*** | -1.69**
+ Species [virginica] | -2.12*** | -1.19 *
Interactions | |
- Species (versicolor) * Petal Length | | -0.01
- Species (virginica) * Petal Length | | -0.15
+ Species [versicolor] * Petal Length | | -0.01
+ Species [virginica] * Petal Length | | -0.15
Controls | |
Petal Length | 0.90*** | 0.39
----------------------------------------------------------
@@ -123,19 +123,19 @@
---
Code
- print(out, groups = list(Species = c("Species (versicolor)",
- "Species (virginica)"), Interactions = c(
- "Species (versicolor) * Petal Length", "Species (virginica) * Petal Length"),
+ print(out, groups = list(Species = c("Species [versicolor]",
+ "Species [virginica]"), Interactions = c(
+ "Species [versicolor] * Petal Length", "Species [virginica] * Petal Length"),
Controls = "Petal Length"), select = "{estimate}|{p}")
Output
Parameter | Estimate (lm1) | p (lm1) | Estimate (lm2) | p (lm2)
-------------------------------------------------------------------------------------------
Species | | | |
- Species (versicolor) | -1.60 | <0.001 | -1.69 | 0.003
- Species (virginica) | -2.12 | <0.001 | -1.19 | 0.048
+ Species [versicolor] | -1.60 | <0.001 | -1.69 | 0.003
+ Species [virginica] | -2.12 | <0.001 | -1.19 | 0.048
Interactions | | | |
- Species (versicolor) * Petal Length | | | -0.01 | 0.961
- Species (virginica) * Petal Length | | | -0.15 | 0.574
+ Species [versicolor] * Petal Length | | | -0.01 | 0.961
+ Species [virginica] * Petal Length | | | -0.15 | 0.574
Controls | | | |
Petal Length | 0.90 | <0.001 | 0.39 | 0.138
-------------------------------------------------------------------------------------------
@@ -152,7 +152,7 @@
--------------------------------------------------------------------------------
(Intercept) | 0.91 ( 0.75, 1.07) | 0.68 (-0.54, 1.91) | 1.41 ( 1.06, 1.75)
child | -1.23 (-1.39, -1.08) | -1.67 (-1.84, -1.51) | -0.53 (-0.77, -0.29)
- camper (1) | 1.05 ( 0.88, 1.23) | 0.94 ( 0.77, 1.12) | 0.58 ( 0.39, 0.78)
+ camper [1] | 1.05 ( 0.88, 1.23) | 0.94 ( 0.77, 1.12) | 0.58 ( 0.39, 0.78)
zg | | | 0.13 ( 0.05, 0.21)
# Fixed Effects (Zero-Inflation Component)
diff --git a/tests/testthat/test-compare_parameters.R b/tests/testthat/test-compare_parameters.R
index 029f0cf29..272127e37 100644
--- a/tests/testthat/test-compare_parameters.R
+++ b/tests/testthat/test-compare_parameters.R
@@ -31,10 +31,10 @@ withr::with_options(
expect_identical(
out$Parameter,
c(
- "(Intercept)", "Species (versicolor)", "Species (virginica)",
- "Petal Length", "Species (versicolor) * Petal Length",
- "Species (virginica) * Petal Length", "outcome (2)", "outcome (3)",
- "treatment (2)", "treatment (3)", NA, "Observations"
+ "(Intercept)", "Species [versicolor]", "Species [virginica]",
+ "Petal Length", "Species [versicolor] * Petal Length",
+ "Species [virginica] * Petal Length", "outcome [2]", "outcome [3]",
+ "treatment [2]", "treatment [3]", NA, "Observations"
)
)
})
@@ -65,10 +65,10 @@ withr::with_options(
expect_identical(
out$Parameter,
c(
- "(Intercept)", "Species (versicolor)", "Species (virginica)",
- "Petal Length", "Species (versicolor) * Petal Length",
- "Species (virginica) * Petal Length", "outcome (2)", "outcome (3)",
- "treatment (2)", "treatment (3)", NA, "Observations"
+ "(Intercept)", "Species [versicolor]", "Species [virginica]",
+ "Petal Length", "Species [versicolor] * Petal Length",
+ "Species [virginica] * Petal Length", "outcome [2]", "outcome [3]",
+ "treatment [2]", "treatment [3]", NA, "Observations"
)
)
})
diff --git a/tests/testthat/test-include_reference.R b/tests/testthat/test-include_reference.R
index b99cb87b2..4cc45e560 100644
--- a/tests/testthat/test-include_reference.R
+++ b/tests/testthat/test-include_reference.R
@@ -42,3 +42,17 @@ test_that("include_reference, on-the-fly factors", {
expect_equal(attributes(out1)$pretty_names, attributes(out3)$pretty_names, ignore_attr = TRUE)
})
+
+test_that("include_reference, with pretty formatted cut", {
+ data(mtcars)
+ mtcars$mpg_cut <- cut(mtcars$mpg, breaks = c(0, 20, 30, 100))
+ m <- lm(wt ~ mpg_cut, data = mtcars)
+ out <- parameters(m, include_reference = TRUE)
+ expect_identical(
+ attributes(out)$pretty_names,
+ c(
+ `(Intercept)` = "(Intercept)", `mpg_cut(0,20]` = "mpg cut [>0-20]",
+ `mpg_cut(20,30]` = "mpg cut [>20-30]", `mpg_cut(30,100]` = "mpg cut [>30-100]"
+ )
+ )
+})
diff --git a/tests/testthat/test-marginaleffects.R b/tests/testthat/test-marginaleffects.R
index 538e85737..ae1df673f 100644
--- a/tests/testthat/test-marginaleffects.R
+++ b/tests/testthat/test-marginaleffects.R
@@ -102,3 +102,13 @@ test_that("model_parameters defaults to FALSE: Issue #916", {
out2 <- model_parameters(pred, exponentiate = FALSE)
expect_equal(out1$Predicted, out2$Predicted, tolerance = 1e-4)
})
+
+
+test_that("digits and ci_digits for marginaleffects", {
+ data(mtcars)
+ skip_if(getRversion() < "4.2.0")
+ out <- lm(mpg ~ wt, data = mtcars) |>
+ marginaleffects::hypotheses(hypothesis = "10*wt = 0") |>
+ model_parameters(digits = 1)
+ expect_snapshot(out)
+})
diff --git a/tests/testthat/test-pipe.R b/tests/testthat/test-pipe.R
index ff8bd9953..e9d047edf 100644
--- a/tests/testthat/test-pipe.R
+++ b/tests/testthat/test-pipe.R
@@ -13,3 +13,16 @@ test_that("print in pipe", {
"Species [setosa] | 0.00 | | | | "
)
})
+
+test_that("print in pipe, on-the-fly factor", {
+ data(mtcars)
+ out <- capture.output({
+ mtcars |>
+ lm(mpg ~ cut(wt, c(0, 2.5, 3, 5)), data = _) |>
+ model_parameters(include_reference = TRUE)
+ })
+ expect_identical(
+ out[4],
+ "cut(wt, c(0, 2.5, 3, 5)) [>0-2.5] | 0.00 | | | | "
+ )
+})
diff --git a/tests/testthat/test-printing2.R b/tests/testthat/test-printing2.R
index cbd9cd00f..57c186e6e 100644
--- a/tests/testthat/test-printing2.R
+++ b/tests/testthat/test-printing2.R
@@ -49,12 +49,12 @@ withr::with_options(
expect_snapshot(
print(out, groups = list(
Species = c(
- "Species (versicolor)",
- "Species (virginica)"
+ "Species [versicolor]",
+ "Species [virginica]"
),
Interactions = c(
- "Species (versicolor) * Petal Length",
- "Species (virginica) * Petal Length"
+ "Species [versicolor] * Petal Length",
+ "Species [virginica] * Petal Length"
),
Controls = "Petal Length"
))
@@ -62,12 +62,12 @@ withr::with_options(
expect_snapshot(
print(out, groups = list(
Species = c(
- "Species (versicolor)",
- "Species (virginica)"
+ "Species [versicolor]",
+ "Species [virginica]"
),
Interactions = c(
- "Species (versicolor) * Petal Length", # note the unicode char!
- "Species (virginica) * Petal Length"
+ "Species [versicolor] * Petal Length", # note the unicode char!
+ "Species [virginica] * Petal Length"
),
Controls = "Petal Length"
), select = "{estimate}{stars}")
@@ -75,12 +75,12 @@ withr::with_options(
expect_snapshot(
print(out, groups = list(
Species = c(
- "Species (versicolor)",
- "Species (virginica)"
+ "Species [versicolor]",
+ "Species [virginica]"
),
Interactions = c(
- "Species (versicolor) * Petal Length", # note the unicode char!
- "Species (virginica) * Petal Length"
+ "Species [versicolor] * Petal Length", # note the unicode char!
+ "Species [virginica] * Petal Length"
),
Controls = "Petal Length"
), select = "{estimate}|{p}")
diff --git a/vignettes/model_parameters_print.Rmd b/vignettes/model_parameters_print.Rmd
index 2a80f8f06..633458920 100644
--- a/vignettes/model_parameters_print.Rmd
+++ b/vignettes/model_parameters_print.Rmd
@@ -347,12 +347,12 @@ as.data.frame(cp)$Parameter # note the unicode char as interaction mark
# create groups. Interactions only present in 2nd model
print(cp, groups = list(
Species = c(
- "Species (versicolor)",
- "Species (virginica)"
+ "Species [versicolor]",
+ "Species [virginica]"
),
Interactions = c(
- "Species (versicolor) × Petal Length", # note the unicode char!
- "Species (virginica) × Petal Length"
+ "Species [versicolor] × Petal Length", # note the unicode char!
+ "Species [virginica] × Petal Length"
),
Controls = "Petal Length"
))