Skip to content

Commit

Permalink
posterior predictive check for binomial glm with matrix response
Browse files Browse the repository at this point in the history
Fixes #644
  • Loading branch information
strengejacke committed Oct 29, 2023
1 parent 5dc4f80 commit bfc8f8f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 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.7.1
Version: 0.10.7.2
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# performance 0.10.8

## Changes

* Changed behaviour of `check_predictions()` for models from binomial family,
to get comparable plots for different ways of outcome specification. Now,
if the outcome is a proportion, or defined as matrix of trials and successes,
the produced plots are the same (because the models should be the same, too).

## Bug fixes

* Fixed CRAN check erros.

# performance 0.10.7

## Breaking changes
Expand Down
4 changes: 2 additions & 2 deletions R/check_predictions.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ pp_check.glm <- function(object,
out <- tryCatch(
{
matrix_sim <- stats::simulate(object, nsim = iterations, re.form = re_formula, ...)
as.data.frame(sapply(matrix_sim, function(i) i[, 1] / i[, 2], simplify = TRUE))
as.data.frame(sapply(matrix_sim, function(i) i[, 1] / rowSums(i, na.rm = TRUE), simplify = TRUE))

Check warning on line 266 in R/check_predictions.R

View workflow job for this annotation

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

file=R/check_predictions.R,line=266,col=21,[undesirable_function_linter] Function "sapply" is undesirable.
},
error = function(e) {
NULL
Expand All @@ -285,7 +285,7 @@ pp_check.glm <- function(object,
)
resp_string <- insight::find_terms(object)$response

out$y <- response[, 1] / response[, 2]
out$y <- response[, 1] / rowSums(response, na.rm = TRUE)

# safe information about model
if (!is.null(model_info)) {

Check warning on line 291 in R/check_predictions.R

View workflow job for this annotation

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

file=R/check_predictions.R,line=291,col=7,[if_not_else_linter] In a simple if/else statement, prefer `if (A) x else y` to the less-readable `if (!A) y else x`.
Expand Down

0 comments on commit bfc8f8f

Please sign in to comment.