From f8ee53efdfc06b0d5d3c823039347ab8c57c2ed4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 15 Jun 2021 23:20:34 +0200 Subject: [PATCH] https://github.com/easystats/modelbased/issues/120 --- NEWS.md | 5 +++++ R/plot.R | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 8b52d4f61..916e85e19 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,11 @@ numeric predictors, which only allow to predict for values that are actually present in the data. +## Bug fixes + +* Fixed issue with adding raw data points for plots from logistic regression + models, when the response variable was no factor with numeric levels. + # ggeffects 1.1.0 ## New supported models diff --git a/R/plot.R b/R/plot.R index a9e891d1d..194120d78 100644 --- a/R/plot.R +++ b/R/plot.R @@ -881,8 +881,14 @@ plot.ggalleffects <- function(x, # dots / lines for marginal effects if (!is.null(rawdat)) { + # recode binary response to numeric? if so, make sure it starts with 0 + if (identical(attributes(x)$logistic, "1")) { + lowest <- 0 + } else { + lowest <- NULL + } # make sure response is numeric - rawdat$response <- .factor_to_numeric(rawdat$response) + rawdat$response <- .factor_to_numeric(rawdat$response, lowest = lowest) # check if we have a group-variable with at least two groups if (.obj_has_name(rawdat, "group")) {