modelbased icon indicating copy to clipboard operation
modelbased copied to clipboard

estimate_contrasts with transform = "response" for a logistic model does not give estimates in terms of probabilities

Open ManuelSpinola opened this issue 2 years ago • 4 comments

When doing estimate_contrasts with transform = "response" for a logistic model the estimates are not in terms of probabilities like the help page said:

"Thus for a logistic model, "none" will give estimations expressed in log-odds (probabilities on logit scale) and "response" in terms of probabilities."

g <- glm(vs ~ factor(am), data = mtcars, family = binomial())

estimate_contrasts(g, contrast = "am", transform = "response")

Marginal Contrasts Analysis

Level1 | Level2 | Difference |        95% CI |   SE |  df |     z |     p
-------------------------------------------------------------------------
am0    |    am1 |      -0.69 | [-2.13, 0.74] | 0.73 | Inf | -0.95 | 0.344

Marginal contrasts estimated at am
p-value adjustment method: Holm (1979)

ManuelSpinola avatar Oct 14 '22 13:10 ManuelSpinola

Can you update the package and check again? This works for me:

g <- glm(vs ~ factor(am), data = mtcars, family = binomial())

modelbased::estimate_contrasts(g, contrast = "am", transform = "response")
#> Marginal Contrasts Analysis
#> 
#> Level1 | Level2 | Odds ratio |       95% CI |   SE |  df |     z |     p
#> ------------------------------------------------------------------------
#> am0    |    am1 |       0.50 | [0.12, 2.10] | 0.37 | Inf | -0.95 | 0.344
#> 
#> Marginal contrasts estimated at am
#> p-value adjustment method: Holm (1979)

Created on 2022-10-16 by the reprex package (v2.0.1)

DominiqueMakowski avatar Oct 16 '22 08:10 DominiqueMakowski

I really think we should be updating the CRAN version soon.

This issue keeps resurfacing here, and we keep asking users to update to the GitHub version.

IndrajeetPatil avatar Oct 16 '22 08:10 IndrajeetPatil

yes right, I'll submit soon then (I'm testing some of the improvements)

DominiqueMakowski avatar Oct 16 '22 10:10 DominiqueMakowski

Thank you Dominique.

May be I am confused but I was expecting the difference in probabilities not in odds ratios, like the help says.

I can have the difference in probabilities using the emmeans package:

em <- emmeans(g, "am", type = "response") |> regrid()

pairs(em) contrast estimate SE df z.ratio p.value am0 - am1 -0.17 0.177 Inf -0.960 0.3370

El dom, 16 oct 2022 a las 2:47, Dominique Makowski (< @.***>) escribió:

Can you update the package and check again? This works for me:

g <- glm(vs ~ factor(am), data = mtcars, family = binomial()) modelbased::estimate_contrasts(g, contrast = "am", transform = "response")#> Marginal Contrasts Analysis#> #> Level1 | Level2 | Odds ratio | 95% CI | SE | df | z | p#> ------------------------------------------------------------------------#> am0 | am1 | 0.50 | [0.12, 2.10] | 0.37 | Inf | -0.95 | 0.344#> #> Marginal contrasts estimated at am#> p-value adjustment method: Holm (1979)

Created on 2022-10-16 by the reprex package https://reprex.tidyverse.org (v2.0.1)

— Reply to this email directly, view it on GitHub https://github.com/easystats/modelbased/issues/215#issuecomment-1279923541, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFI3FBYJVRRHYHDZ7KJNCP3WDO6JVANCNFSM6AAAAAARFIHXWA . You are receiving this because you authored the thread.Message ID: @.***>

-- Manuel Spínola, Ph.D. Instituto Internacional en Conservación y Manejo de Vida Silvestre Universidad Nacional Apartado 1350-3000 Heredia COSTA RICA @.*** @.> @. Teléfono: (506) 8706 - 4662 Institutional website: ICOMVIS http://www.icomvis.una.ac.cr/index.php/manuel Blog sobre Ciencia de Datos: https://mspinola-ciencia-de-datos.netlify.app

ManuelSpinola avatar Oct 16 '22 13:10 ManuelSpinola