Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 15 commits into from
Nov 4, 2024
18 changes: 10 additions & 8 deletions R/1_model_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
#'
#' Compared to fixed effects (or single-level) models, determining appropriate
#' df for Wald-based inference in mixed models is more difficult.
#' See [the R GLMM FAQ](https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#what-are-the-p-values-listed-by-summaryglmerfit-etc.-are-they-reliable)

Check warning on line 183 in R/1_model_parameters.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/1_model_parameters.R,line=183,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 151 characters.

Check warning on line 183 in R/1_model_parameters.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/1_model_parameters.R,line=183,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 151 characters.
#' for a discussion.
#'
#' Several approximate methods for computing df are available, but you should
Expand Down Expand Up @@ -446,14 +446,16 @@
#' 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 @@ -3,7 +3,7 @@
#' @inheritParams print.parameters_model
#' @rdname print.parameters_model
#' @export
format.parameters_model <- function(x,

Check warning on line 6 in R/format.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/format.R,line=6,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this function from 71 to at most 40.
pretty_names = TRUE,
split_components = TRUE,
select = NULL,
Expand Down Expand Up @@ -243,7 +243,7 @@
#' @rdname print.compare_parameters
#' @inheritParams print.parameters_model
#' @export
format.compare_parameters <- function(x,

Check warning on line 246 in R/format.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/format.R,line=246,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this function from 43 to at most 40.
split_components = TRUE,
select = NULL,
digits = 2,
Expand Down Expand Up @@ -613,11 +613,6 @@
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 @@ -750,7 +745,7 @@


# footer: type of uncertainty interval
.print_footer_cimethod <- function(x) {

Check warning on line 748 in R/format.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/format.R,line=748,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this function from 45 to at most 40.
if (isTRUE(getOption("parameters_cimethod", TRUE))) {
# get attributes
ci_method <- .additional_arguments(x, "ci_method", NULL)
Expand Down Expand Up @@ -853,7 +848,7 @@
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 @@
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 @@
# 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
Loading