Skip to content

Commit

Permalink
support for quantile regression and mixed effects quantile regression (
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke authored Feb 16, 2024
1 parent 3250fd7 commit 41d60d0
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 78 deletions.
3 changes: 2 additions & 1 deletion 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.10.8.14
Version: 0.10.8.15
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down Expand Up @@ -128,6 +128,7 @@ Suggests:
patchwork,
pscl,
psych,
quantreg,
qqplotr (>= 0.0.6),
randomForest,
rempsyc,
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ S3method(check_outliers,metagen)
S3method(check_outliers,numeric)
S3method(check_outliers,rma)
S3method(check_outliers,rma.uni)
S3method(check_outliers,rq)
S3method(check_outliers,rqs)
S3method(check_outliers,rqss)
S3method(check_overdispersion,default)
S3method(check_overdispersion,fixest)
S3method(check_overdispersion,fixest_multi)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
* Fixed edge cases in `check_collinearity()` and `check_outliers()` for models
with response variables of classes `Date`, `POSIXct`, `POSIXlt` or `difftime`.

* Fixed issue with `check_model()` for models of package *quantreg*.

# performance 0.10.8

## Changes
Expand Down
9 changes: 9 additions & 0 deletions R/check_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1987,3 +1987,12 @@ check_outliers.lmrob <- check_outliers.glmmTMB

#' @export
check_outliers.glmrob <- check_outliers.glmmTMB

#' @export
check_outliers.rq <- check_outliers.glmmTMB

#' @export
check_outliers.rqs <- check_outliers.glmmTMB

#' @export
check_outliers.rqss <- check_outliers.glmmTMB
8 changes: 1 addition & 7 deletions R/model_performance.bayesian.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#'
#' - **PCP**: percentage of correct predictions, see [performance_pcp()].
#'
#' @examplesIf require("rstanarm") && require("rstantools") && require("BayesFactor")
#' @examplesIf require("rstanarm") && require("rstantools")
#' \donttest{
#' model <- suppressWarnings(rstanarm::stan_glm(
#' mpg ~ wt + cyl,
Expand All @@ -59,12 +59,6 @@
#' refresh = 0
#' ))
#' model_performance(model)
#'
#' model <- BayesFactor::generalTestBF(carb ~ am + mpg, mtcars)
#'
#' model_performance(model)
#' model_performance(model[3])
#' model_performance(model, average = TRUE)
#' }
#' @seealso [r2_bayes]
#' @references Gelman, A., Goodrich, B., Gabry, J., and Vehtari, A. (2018).
Expand Down
20 changes: 1 addition & 19 deletions R/r2_bayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#' `r2_posterior()` is the actual workhorse for `r2_bayes()` and
#' returns a posterior sample of Bayesian R2 values.
#'
#' @examplesIf require("rstanarm") && require("rstantools") && require("BayesFactor") && require("brms")
#' @examplesIf require("rstanarm") && require("rstantools") && require("brms")
#' library(performance)
#' \donttest{
#' model <- suppressWarnings(rstanarm::stan_glm(
Expand All @@ -53,24 +53,6 @@
#' r2_bayes(model)
#' }
#'
#' BFM <- BayesFactor::generalTestBF(mpg ~ qsec + gear, data = mtcars, progress = FALSE)
#' FM <- BayesFactor::lmBF(mpg ~ qsec + gear, data = mtcars)
#'
#' r2_bayes(FM)
#' r2_bayes(BFM[3])
#' r2_bayes(BFM, average = TRUE) # across all models
#'
#' # with random effects:
#' mtcars$gear <- factor(mtcars$gear)
#' model <- BayesFactor::lmBF(
#' mpg ~ hp + cyl + gear + gear:wt,
#' mtcars,
#' progress = FALSE,
#' whichRandom = c("gear", "gear:wt")
#' )
#'
#' r2_bayes(model)
#'
#' \donttest{
#' model <- suppressWarnings(brms::brm(
#' mpg ~ wt + cyl,
Expand Down
8 changes: 1 addition & 7 deletions man/model_performance.stanreg.Rd

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

20 changes: 1 addition & 19 deletions man/r2_bayes.Rd

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

8 changes: 8 additions & 0 deletions tests/testthat/test-check_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@ test_that("`check_model()` for invalid models", {
m1 <- lm(y ~ 1, data = dd)
expect_error(check_model(m1))
})

test_that("`check_model()` works for quantreg", {
skip_if_not_installed("quantreg")
data(engel, package = "quantreg")
qm <- quantreg::rq(foodexp ~ income, data = engel)
x <- check_model(qm, verbose = FALSE)
expect_s3_class(x, "check_model")
})
26 changes: 1 addition & 25 deletions vignettes/r2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ knitr::opts_chunk$set(
)
options(digits = 2)
pkgs <- c(
"effectsize", "BayesFactor", "lme4", "rstanarm"
)
pkgs <- c("effectsize", "lme4", "rstanarm")
successfully_loaded <- sapply(pkgs, requireNamespace, quietly = TRUE)
if (all(successfully_loaded)) {
library(performance)
library(effectsize)
library(BayesFactor)
library(lme4)
library(rstanarm)
}
Expand Down Expand Up @@ -147,27 +144,6 @@ model <- stan_lmer(Petal.Length ~ Petal.Width + (1 | Species), data = iris, refr
r2(model)
```

Let's look at another regression analysis carried out with `{BayesFactor}` package.

```{r, eval=successfully_loaded["BayesFactor"] && utils::packageVersion("BayesFactor") >= package_version("0.9.12-4.3")}
library(BayesFactor)
data(puzzles)
m1 <- anovaBF(extra ~ group + ID,
data = sleep,
whichRandom = "ID", progress = FALSE
)
r2(m1)
m2 <- generalTestBF(RT ~ shape * color + ID,
data = puzzles, whichRandom = "ID",
neverExclude = "ID", progress = FALSE
)
r2(m2)
```

# Comparing change in R2 using Cohen's *f*

Cohen's $f$ (of [ANOVA fame](https://easystats.github.io/effectsize/articles/anovaES.html)) can be used as a measure of effect size in the context of sequential multiple regression (i.e., [**nested models**](https://easystats.github.io/performance/reference/test_performance.html)).
Expand Down

0 comments on commit 41d60d0

Please sign in to comment.