Skip to content

Commit

Permalink
Logistic models: Be less verbose by default + be less scary for users…
Browse files Browse the repository at this point in the history
… with less red (#1035)

* Logistic models: Be less verbose by default + be less scary for users with less red
Fixes #1034

* model info

* no color

* thresholds

* minor

* RD

* version

* update tests

* typo

* docs

* fix

* remove interpretation

* update test
  • Loading branch information
strengejacke authored Nov 4, 2024
1 parent 6533602 commit 29ed890
Show file tree
Hide file tree
Showing 19 changed files with 150 additions and 137 deletions.
18 changes: 10 additions & 8 deletions R/1_model_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,16 @@ parameters <- model_parameters
#' coefficients (and related confidence intervals). This is typical for
#' logistic regression, or more generally speaking, for models with log or
#' logit links. It is also recommended to use `exponentiate = TRUE` for models
#' with log-transformed response values. **Note:** Delta-method standard
#' errors are also computed (by multiplying the standard errors by the
#' transformed coefficients). This is to mimic behaviour of other software
#' packages, such as Stata, but these standard errors poorly estimate
#' uncertainty for the transformed coefficient. The transformed confidence
#' interval more clearly captures this uncertainty. For `compare_parameters()`,
#' `exponentiate = "nongaussian"` will only exponentiate coefficients from
#' non-Gaussian families.
#' with log-transformed response values. For models with a log-transformed
#' response variable, when `exponentiate = TRUE`, a one-unit increase in the
#' predictor is associated with multiplying the outcome by that predictor's
#' coefficient. **Note:** Delta-method standard errors are also computed (by
#' multiplying the standard errors by the transformed coefficients). This is
#' to mimic behaviour of other software packages, such as Stata, but these
#' standard errors poorly estimate uncertainty for the transformed
#' coefficient. The transformed confidence interval more clearly captures this
#' uncertainty. For `compare_parameters()`, `exponentiate = "nongaussian"`
#' will only exponentiate coefficients from non-Gaussian families.
#' @param p_adjust Character vector, if not `NULL`, indicates the method to
#' adjust p-values. See [`stats::p.adjust()`] for details. Further
#' possible adjustment methods are `"tukey"`, `"scheffe"`,
Expand Down
15 changes: 3 additions & 12 deletions R/format.R
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,6 @@ format.parameters_sem <- function(x,
footer <- .add_footer_text(footer, footer_text, type, is_ggeffects)
}

# add color code, if we have a footer
if (!is.null(footer) && type == "text") {
footer <- c(footer, "blue")
}

# if we have two trailing newlines, remove one
if (identical(type, "text") && !is.null(footer) && endsWith(footer[1], "\n\n")) {
footer[1] <- substr(footer[1], 0, nchar(x) - 1)
Expand Down Expand Up @@ -853,7 +848,7 @@ format.parameters_sem <- function(x,
msg <- paste(msg, "Uncertainty intervals for random effect variances computed using a Wald z-distribution approximation.") # nolint
}

insight::format_alert(msg)
insight::format_alert(insight::color_text(msg, "yellow"))
}
}
}
Expand Down Expand Up @@ -884,10 +879,6 @@ format.parameters_sem <- function(x,
spurious_coefficients <- NULL
}
} else if (.is_valid_exponentiate_argument(exponentiate) && isTRUE(.additional_arguments(x, "log_response", FALSE))) { # nolint
msg <- c(
"This model has a log-transformed response variable, and exponentiated parameters are reported.",
"A one-unit increase in the predictor is associated with multiplying the outcome by that predictor's coefficient." # nolint
)
# don't show warning about complete separation
spurious_coefficients <- NULL
}
Expand All @@ -899,9 +890,9 @@ format.parameters_sem <- function(x,
# check for complete separation coefficients or possible issues with
# too few data points
if (!is.null(spurious_coefficients) && logit_model) {
if (any(spurious_coefficients > 100)) {
if (any(spurious_coefficients > 50)) {
msg <- c(msg, "Some coefficients are very large, which may indicate issues with complete separation.") # nolint
} else if (any(spurious_coefficients > 25)) {
} else if (any(spurious_coefficients > 15)) {
msg <- c(msg, "Some coefficients seem to be rather large, which may indicate issues with (quasi) complete separation. Consider using bias-corrected or penalized regression models.") # nolint
}
}
Expand Down
18 changes: 10 additions & 8 deletions man/compare_parameters.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions man/model_parameters.averaging.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions man/model_parameters.cgam.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions man/model_parameters.default.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions man/model_parameters.glht.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions man/model_parameters.merMod.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions man/model_parameters.mira.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions man/model_parameters.mlm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions man/model_parameters.rma.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 29ed890

Please sign in to comment.