From c2aa63873d913448bd9ef380334e8afb97dd3026 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 11 Oct 2024 08:55:32 +0200 Subject: [PATCH] Inconsistency in the use of parenthesis between `parameters()` and `compare_parameters()` Fixes #1028 --- DESCRIPTION | 2 +- NEWS.md | 3 + R/1_model_parameters.R | 2 +- R/compare_parameters.R | 9 +-- R/print.compare_parameters.R | 2 +- R/print.parameters_model.R | 35 ++++++---- R/print_html.R | 6 ++ R/print_md.R | 12 +++- man/bootstrap_parameters.Rd | 8 +-- man/compare_parameters.Rd | 69 +++++++++++--------- man/display.parameters_model.Rd | 69 +++++++++++--------- man/model_parameters.BFBayesFactor.Rd | 16 ++--- man/model_parameters.Rd | 2 +- man/model_parameters.befa.Rd | 16 ++--- man/model_parameters.stanreg.Rd | 8 +-- man/print.compare_parameters.Rd | 71 ++++++++++++--------- man/print.parameters_model.Rd | 69 +++++++++++--------- man/simulate_parameters.Rd | 16 ++--- tests/testthat/_snaps/compare_parameters.md | 10 +-- 19 files changed, 241 insertions(+), 184 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 950418f45..46b71549c 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.19 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NEWS.md b/NEWS.md index 7d5eaa314..432246b01 100644 --- a/NEWS.md +++ b/NEWS.md @@ -34,6 +34,9 @@ * 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 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/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/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 | +-------------------------+-----------------------+--------+----------------------+--------+