strengejacke/ggeffects

back_transform doesn't change results

Closed this issue · 2 comments

I'm trying to get emmeans from a logistic regression, and want linear predictors as output (because we're also doing multiple imputation, and these need to be pooled). Regardless of what option I use for back_transform, I get the same results. Is back_transform just not working or is there something else I should be using? (reprex below)

library(ggeffects)
data(efc)
fit <- glm(
tot_sc_e ~ c12hour + e42dep + e17age + I(e17age^2) + I(e17age^3),
data = efc,
family = poisson()
)

ggemmeans(fit, terms = list("c12hour" = c(10, 20, 30, 40)),
back_transform = TRUE)
ggemmeans(fit, terms = list("c12hour" = c(10, 20, 30, 40)),
back_transform = FALSE)

predict_response(fit, terms = list("c12hour" = c(10, 20, 30, 40)),
back_transform = TRUE)
predict_response(fit, terms = list("c12hour" = c(10, 20, 30, 40)),
back_transform = FALSE)

back_transform is only used for log, sqrt, exp and similar transformations, not for link-/link-inverse transformations. So you can't return predictions on a different scale than the response scale.

However, pool_predictions(), which can be used to pool multiple imputed data, pools all predicted values on the link-scale and after that transforms to the response-scale. I updated the docs to clarify this.

Ok, thanks for the clarification!