Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ revdep/data.sqlite
revdep/
docs
*.tar.gz
*.Rcheck/
report_*.tar.gz
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: report
Type: Package
Title: Automated Reporting of Results and Statistical Models
Version: 0.6.1.2
Version: 0.6.1.3
Authors@R:
c(person(given = "Dominique",
family = "Makowski",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# report 0.6.x

New features

* `report.glm()`: added explainability guidance for interpreting GLM coefficients (odds ratios for binomial models, rate ratios for Poisson models) to help users understand how to transform coefficients for easier interpretation (#484)

Bug fixes

* Enhanced copilot environment setup with complete reprex dependency management (pandoc, knitr, rmarkdown, clipr) to prevent "reprex appears to crash R" errors
Expand Down
32 changes: 31 additions & 1 deletion R/report.glm.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,37 @@ report_model.glm <- report_model.lm
report_performance.glm <- report_performance.lm

#' @export
report_info.glm <- report_info.lm
report_info.glm <- function(x,
effectsize = NULL,
include_effectsize = FALSE,
parameters = NULL,
...) {
# Get the standard info from the lm method
info_text <- report_info.lm(x, effectsize = effectsize, include_effectsize = include_effectsize, parameters = parameters, ...)

# Add GLM-specific explainability guidance
model_info <- insight::model_info(x)
explainability_text <- ""

if (model_info$is_binomial) {
explainability_text <- " For easier interpretation, the odds ratio can be calculated by taking the exponent of the coefficient (e.g., exp(beta))."
} else if (model_info$is_poisson) {
explainability_text <- " For easier interpretation, the rate ratio can be calculated by taking the exponent of the coefficient (e.g., exp(beta))."
} else if (!model_info$is_linear) {
explainability_text <- " For easier interpretation, transformed coefficients can be calculated using the appropriate link function inverse (e.g., exp(beta) for log-link models)."
}

# Combine the existing info text with the new explainability text
combined_text <- paste0(as.character(info_text), explainability_text)

# Preserve the summary attribute from the original info_text
summary_text <- summary(info_text)
if (!is.null(explainability_text) && nzchar(explainability_text)) {
summary_text <- paste0(as.character(summary_text), explainability_text)
}

as.report_info(combined_text, summary = summary_text)
}

#' @export
report_text.glm <- report_text.lm