Skip to content

performance_cv() fails with method = "loo" (object ‘test_resd’ not found)#911

Merged
strengejacke merged 3 commits into
mainfrom
strengejacke/issue896
May 21, 2026
Merged

performance_cv() fails with method = "loo" (object ‘test_resd’ not found)#911
strengejacke merged 3 commits into
mainfrom
strengejacke/issue896

Conversation

@strengejacke
Copy link
Copy Markdown
Member

Fixes #896

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the performance_cv function by modularizing its logic, adding metric validation, and implementing a fast Leave-One-Out (LOO) approximation for linear models. It also removes the as.data.frame.performance_cv S3 method, standardizes documentation links, and updates the test suite. Reviewer feedback highlights a style guide violation regarding warning formatting and an inconsistency between the documentation and validation logic for the ELPD metric.

Comment thread R/performance_cv.R Outdated
Comment on lines +147 to +153
message(insight::color_text(
insight::format_message(
"Requested number of folds (k) larger than the sample size.",
"'k' set equal to the sample size (leave-one-out [LOO])."
),
color = "yellow"
))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the repository style guide, user-facing warnings should be issued using insight::format_warning(). This ensures consistent formatting and behavior across the easystats ecosystem. The current implementation using message() and insight::color_text() is less idiomatic for this project.

      insight::format_warning(
        "Requested number of folds (k) larger than the sample size.",
        "'k' set equal to the sample size (leave-one-out [LOO])."
      )
References
  1. Use the insight package's functions for user-facing messages: For warnings: insight::format_warning() (link)

Comment thread R/performance_cv.R Outdated
#' leave-one-out (`"loo"`). If `data` is supplied, this argument is ignored.
#' @param metrics Can be `"all"`, `"common"` or a character vector of metrics to be
#' computed (some of `c("ELPD", "Deviance", "MSE", "RMSE", "R2")`). "common" will
#' computed (some of `"ELPD"`, `"MSE"`, `"RMSE"`, `"R2"`). `"common"` will
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The documentation lists ELPD as a possible metric to be computed. However, the validation logic at line 59 explicitly excludes it from the allowed set, which will result in a 'not yet supported' error if a user tries to use it. To avoid confusion, consider removing ELPD from the documentation string until it is fully implemented, or update the validation set to allow it if the intention is to provide a specific 'not yet supported' message for this metric.

@strengejacke strengejacke merged commit 203ee75 into main May 21, 2026
12 of 22 checks passed
@strengejacke strengejacke deleted the strengejacke/issue896 branch May 21, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

performance_cv() fails with method = "loo" (object ‘test_resd’ not found)

1 participant