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/R/utils_format.R b/R/utils_format.R index d672d494a..deec16664 100644 --- a/R/utils_format.R +++ b/R/utils_format.R @@ -440,6 +440,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/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-pipe.R b/tests/testthat/test-pipe.R index b6502e11b..e9d047edf 100644 --- a/tests/testthat/test-pipe.R +++ b/tests/testthat/test-pipe.R @@ -23,6 +23,6 @@ test_that("print in pipe, on-the-fly factor", { }) expect_identical( out[4], - "cut(wt, c(0, 2.5, 3, 5)) [(0,2.5]] | 0.00 | | | | " + "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" ))