Skip to content

Commit

Permalink
Merge branch 'main' into strengejacke/issue697
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke authored Jan 2, 2025
2 parents af17c05 + 98f2f6a commit 65efe0a
Show file tree
Hide file tree
Showing 67 changed files with 321 additions and 325 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: performance
Title: Assessment of Regression Models Performance
Version: 0.12.4.7
Version: 0.12.4.16
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down Expand Up @@ -74,7 +74,7 @@ Depends:
R (>= 3.6)
Imports:
bayestestR (>= 0.15.0),
insight (>= 0.20.5),
insight (>= 1.0.0),
datawizard (>= 0.13.0),
stats,
utils
Expand Down Expand Up @@ -160,4 +160,4 @@ Config/Needs/website:
r-lib/pkgdown,
easystats/easystatstemplate
Config/rcmdcheck/ignore-inconsequential-notes: true
Remotes: easystats/insight
Remotes: easystats/datawizard, easystats/see, easystats/insight
4 changes: 3 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ S3method(as.data.frame,performance_score)
S3method(as.data.frame,r2_bayes)
S3method(as.data.frame,r2_loo)
S3method(as.data.frame,r2_nakagawa)
S3method(as.numeric,check_outliers)
S3method(as.double,check_outliers)
S3method(as.double,performance_roc)
S3method(check_autocorrelation,default)
S3method(check_collinearity,BFBayesFactor)
S3method(check_collinearity,MixMod)
Expand Down Expand Up @@ -473,6 +474,7 @@ S3method(r2_mcfadden,clm)
S3method(r2_mcfadden,clm2)
S3method(r2_mcfadden,cpglm)
S3method(r2_mcfadden,glm)
S3method(r2_mcfadden,glmmTMB)
S3method(r2_mcfadden,glmx)
S3method(r2_mcfadden,logitmfx)
S3method(r2_mcfadden,logitor)
Expand Down
19 changes: 19 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Breaking changes

* `check_outliers()` with `method = "optics"` now returns a further refined
cluster selection, by passing the `optics_xi` argument to `dbscan::extractXi()`.

* Deprecated arguments and alias-function-names have been removed.

* Argument names in `check_model()` that refer to plot-aesthetics (like
Expand All @@ -13,6 +16,22 @@

* Increased accuracy for `check_convergence()` for *glmmTMB* models.

* `r2()` and `r2_mcfadden()` now support beta-binomial (non-mixed) models from
package *glmmTMB*.

* An `as.numeric()` resp. `as.double()` method for objects of class
`performance_roc` was added.

* Improved documentation for `performance_roc()`.

## Bug fixes

* `check_outliers()` did not warn that no numeric variables were found when only
the response variable was numeric, but all relevant predictors were not.

* `check_collinearity()` did not work for glmmTMB models when zero-inflation
component was set to `~0`.

# performance 0.12.4

## Changes
Expand Down
2 changes: 0 additions & 2 deletions R/check_autocorrelation.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ check_autocorrelation.default <- function(x, nsim = 1000, ...) {
}



# methods ------------------------------

#' @export
Expand Down Expand Up @@ -81,7 +80,6 @@ print.check_autocorrelation <- function(x, ...) {
}



# utilities -------------------------------

.durbWats <- function(.residuals) {
Expand Down
3 changes: 0 additions & 3 deletions R/check_clusterstructure.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ check_clusterstructure <- function(x,
}



#' @export
plot.check_clusterstructure <- function(x, ...) {
# Can be reimplemented with ggplot in see
Expand All @@ -88,7 +87,6 @@ plot.check_clusterstructure <- function(x, ...) {
}



#' @keywords internal
.clusterstructure_dm <- function(x, distance = "euclidean", method = "ward.D2") {
d <- stats::dist(x, method = distance)
Expand All @@ -97,7 +95,6 @@ plot.check_clusterstructure <- function(x, ...) {
}



#' @keywords internal
.clusterstructure_hopkins <- function(x, distance = "euclidean") {
# This is based on the hopkins() function from the clustertend package
Expand Down
48 changes: 24 additions & 24 deletions R/check_collinearity.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@
#' This portion of multicollinearity among the component terms of an
#' interaction is also called "inessential ill-conditioning", which leads to
#' inflated VIF values that are typically seen for models with interaction
#' terms _(Francoeur 2013)_.
#' terms _(Francoeur 2013)_. Centering interaction terms can resolve this
#' issue _(Kim and Jung 2024)_.
#'
#' @section Multicollinearity and Polynomial Terms:
#' Polynomial transformations are considered a single term and thus VIFs are
#' not calculated between them.
#'
#' @section Concurvity for Smooth Terms in Generalized Additive Models:
#' `check_concurvity()` is a wrapper around `mgcv::concurvity()`, and can be
Expand All @@ -91,26 +96,30 @@
#' @references
#'
#' - Francoeur, R. B. (2013). Could Sequential Residual Centering Resolve
#' Low Sensitivity in Moderated Regression? Simulations and Cancer Symptom
#' Clusters. Open Journal of Statistics, 03(06), 24-44.
#' Low Sensitivity in Moderated Regression? Simulations and Cancer Symptom
#' Clusters. Open Journal of Statistics, 03(06), 24-44.
#'
#' - James, G., Witten, D., Hastie, T., and Tibshirani, R. (eds.). (2013). An
#' introduction to statistical learning: with applications in R. New York:
#' Springer.
#'
#' - James, G., Witten, D., Hastie, T., and Tibshirani, R. (eds.). (2013).
#' An introduction to statistical learning: with applications in R. New York:
#' Springer.
#' - Kim, Y., & Jung, G. (2024). Understanding linear interaction analysis with
#' causal graphs. British Journal of Mathematical and Statistical Psychology,
#' 00, 1–14.
#'
#' - Marcoulides, K. M., and Raykov, T. (2019). Evaluation of Variance
#' Inflation Factors in Regression Models Using Latent Variable Modeling
#' Methods. Educational and Psychological Measurement, 79(5), 874–882.
#' Inflation Factors in Regression Models Using Latent Variable Modeling
#' Methods. Educational and Psychological Measurement, 79(5), 874–882.
#'
#' - McElreath, R. (2020). Statistical rethinking: A Bayesian course with
#' examples in R and Stan. 2nd edition. Chapman and Hall/CRC.
#' examples in R and Stan. 2nd edition. Chapman and Hall/CRC.
#'
#' - Vanhove, J. (2019). Collinearity isn't a disease that needs curing.
#' [webpage](https://janhove.github.io/posts/2019-09-11-collinearity/)
#' [webpage](https://janhove.github.io/posts/2019-09-11-collinearity/)
#'
#' - Zuur AF, Ieno EN, Elphick CS. A protocol for data exploration to avoid
#' common statistical problems: Data exploration. Methods in Ecology and
#' Evolution (2010) 1:3–14.
#' common statistical problems: Data exploration. Methods in Ecology and
#' Evolution (2010) 1:3–14.
#'
#' @family functions to check model assumptions and and assess model quality
#'
Expand Down Expand Up @@ -139,7 +148,6 @@ check_collinearity <- function(x, ...) {
multicollinearity <- check_collinearity



# default ------------------------------

#' @rdname check_collinearity
Expand All @@ -150,7 +158,6 @@ check_collinearity.default <- function(x, ci = 0.95, verbose = TRUE, ...) {
}



# methods -------------------------------------------

#' @export
Expand Down Expand Up @@ -193,7 +200,7 @@ plot.check_collinearity <- function(x, ...) {
x <- insight::format_table(x)
x <- datawizard::data_rename(
x,
pattern = "SE_factor",
select = "SE_factor",
replacement = "Increased SE",
verbose = FALSE
)
Expand All @@ -218,7 +225,6 @@ plot.check_collinearity <- function(x, ...) {
}



# other classes ----------------------------------

#' @export
Expand Down Expand Up @@ -294,7 +300,6 @@ check_collinearity.betaor <- check_collinearity.logitor
check_collinearity.betamfx <- check_collinearity.logitor



# zi-models -------------------------------------

#' @rdname check_collinearity
Expand Down Expand Up @@ -353,7 +358,6 @@ check_collinearity.zerocount <- function(x,
}



# utilities ---------------------------------

.check_collinearity_zi_model <- function(x, component, ci = 0.95, verbose = TRUE) {
Expand Down Expand Up @@ -403,9 +407,8 @@ check_collinearity.zerocount <- function(x,
}



.check_collinearity <- function(x, component, ci = 0.95, verbose = TRUE) {

Check warning on line 410 in R/check_collinearity.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/check_collinearity.R,line=410,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this function from 44 to at most 40.
v <- insight::get_varcov(x, component = component, verbose = FALSE)
v <- .safe(insight::get_varcov(x, component = component, verbose = FALSE))

# sanity check
if (is.null(v)) {
Expand Down Expand Up @@ -514,7 +517,7 @@ check_collinearity.zerocount <- function(x,
if (!is.null(insight::find_interactions(x)) && any(result > 10) && isTRUE(verbose)) {
insight::format_alert(
"Model has interaction terms. VIFs might be inflated.",
"You may check multicollinearity among predictors of a model without interaction terms."
"Try to center the variables used for the interaction, or check multicollinearity among predictors of a model without interaction terms." # nolint
)
}

Expand Down Expand Up @@ -577,7 +580,6 @@ check_collinearity.zerocount <- function(x,
}



.term_assignments <- function(x, component, verbose = TRUE) {
tryCatch(
{
Expand Down Expand Up @@ -613,7 +615,6 @@ check_collinearity.zerocount <- function(x,
}



.find_term_assignment <- function(x, component, verbose = TRUE) {
pred <- insight::find_predictors(x)[[component]]

Expand Down Expand Up @@ -648,7 +649,6 @@ check_collinearity.zerocount <- function(x,
}



.zi_term_assignment <- function(x, component = "zero_inflated", verbose = TRUE) {
tryCatch(
{
Expand Down
1 change: 0 additions & 1 deletion R/check_concurvity.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ check_concurvity.gam <- function(x, ...) {
}



# methods ---------------------------------

#' @export
Expand Down
5 changes: 0 additions & 5 deletions R/check_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ check_distribution <- function(model) {
}



# default -----------------------------

#' @export
Expand Down Expand Up @@ -106,7 +105,6 @@ check_distribution.default <- function(model) {
}



# methods --------------------------

#' @export
Expand Down Expand Up @@ -160,7 +158,6 @@ plot.check_distribution_numeric <- function(x, ...) {
}



# other classes -------------------

#' @export
Expand All @@ -184,7 +181,6 @@ check_distribution.numeric <- function(model) {
}



# utilities -----------------------------

.extract_features <- function(x, type = NULL) {
Expand Down Expand Up @@ -243,7 +239,6 @@ check_distribution.numeric <- function(model) {
}



.is_integer <- function(x) {
tryCatch(
ifelse(is.infinite(x), FALSE, x %% 1 == 0),
Expand Down
7 changes: 0 additions & 7 deletions R/check_factorstructure.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ check_factorstructure <- function(x, n = NULL, ...) {
}





#' @rdname check_factorstructure
#' @export
check_kmo <- function(x, n = NULL, ...) {
Expand Down Expand Up @@ -169,9 +166,6 @@ check_kmo <- function(x, n = NULL, ...) {
}





#' @rdname check_factorstructure
#' @export
check_sphericity_bartlett <- function(x, n = NULL, ...) {
Expand Down Expand Up @@ -213,7 +207,6 @@ check_sphericity_bartlett <- function(x, n = NULL, ...) {
}



# Helpers -----------------------------------------------------------------

#' @keywords internal
Expand Down
2 changes: 0 additions & 2 deletions R/check_heterogeneity_bias.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ check_heterogeneity_bias <- function(x, select = NULL, by = NULL, nested = FALSE
}




#' @export
print.check_heterogeneity_bias <- function(x, ...) {
cat("Possible heterogeneity bias due to following predictors: ")
Expand Down
2 changes: 0 additions & 2 deletions R/check_heteroscedasticity.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ check_heteroscedasticity.default <- function(x, ...) {
}



# methods -----------------------

#' @export
Expand Down Expand Up @@ -112,7 +111,6 @@ plot.check_heteroscedasticity <- function(x, ...) {
}



# utilities -----------------------

.sigma <- function(x) {
Expand Down
3 changes: 0 additions & 3 deletions R/check_homogeneity.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ check_homogeneity <- function(x, method = c("bartlett", "fligner", "levene", "au
}



# default -------------------------

#' @export
Expand Down Expand Up @@ -105,7 +104,6 @@ check_homogeneity.default <- function(x, method = c("bartlett", "fligner", "leve
}



# methods -----------------------

#' @export
Expand All @@ -130,7 +128,6 @@ plot.check_homogeneity <- function(x, ...) {
}



# other classes -----------------------------

#' @rdname check_homogeneity
Expand Down
1 change: 0 additions & 1 deletion R/check_htest.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ check_symmetry.htest <- function(x, ...) {
# }



# Print -------------------------------------------------------------------

#' @export
Expand Down
Loading

0 comments on commit 65efe0a

Please sign in to comment.