Skip to content

mismatch between {emmeans}\s and model_parameters()'s adjusted p-values #1103

Open
@mattansb

Description

@mattansb
library(emmeans)
library(parameters)

warp.lm <- lm(breaks ~ wool * tension, data = warpbreaks)

myc <- emmeans (warp.lm,  ~ wool + tension) |> 
  contrast("pairwise")

myc
#>  contrast  estimate   SE df t.ratio p.value
#>  A L - B L   16.333 5.16 48   3.167  0.0302
#>  A L - A M   20.556 5.16 48   3.986  0.0030
#>  A L - B M   15.778 5.16 48   3.059  0.0398
#>  A L - A H   20.000 5.16 48   3.878  0.0041
#>  A L - B H   25.778 5.16 48   4.998  0.0001
#>  B L - A M    4.222 5.16 48   0.819  0.9627
#>  B L - B M   -0.556 5.16 48  -0.108  1.0000
#>  B L - A H    3.667 5.16 48   0.711  0.9797
#>  B L - B H    9.444 5.16 48   1.831  0.4561
#>  A M - B M   -4.778 5.16 48  -0.926  0.9377
#>  A M - A H   -0.556 5.16 48  -0.108  1.0000
#>  A M - B H    5.222 5.16 48   1.013  0.9115
#>  B M - A H    4.222 5.16 48   0.819  0.9627
#>  B M - B H   10.000 5.16 48   1.939  0.3919
#>  A H - B H    5.778 5.16 48   1.120  0.8706
#> 
#> P value adjustment: tukey method for comparing a family of 6 estimates

model_parameters(myc)
#> contrast  | Coefficient |   SE |          95% CI | t(48) |      p
#> -----------------------------------------------------------------
#> A L - B L |       16.33 | 5.16 | [  5.96, 26.70] |  3.17 | 0.133 
#> A L - A M |       20.56 | 5.16 | [ 10.19, 30.93] |  3.99 | 0.016 
#> A L - B M |       15.78 | 5.16 | [  5.41, 26.15] |  3.06 | 0.169 
#> A L - A H |       20.00 | 5.16 | [  9.63, 30.37] |  3.88 | 0.022 
#> A L - B H |       25.78 | 5.16 | [ 15.41, 36.15] |  5.00 | < .001
#> B L - A M |        4.22 | 5.16 | [ -6.15, 14.59] |  0.82 | > .999
#> B L - B M |       -0.56 | 5.16 | [-10.93,  9.81] | -0.11 | > .999
#> B L - A H |        3.67 | 5.16 | [ -6.70, 14.04] |  0.71 | > .999
#> B L - B H |        9.44 | 5.16 | [ -0.93, 19.81] |  1.83 | 0.873 
#> A M - B M |       -4.78 | 5.16 | [-15.15,  5.59] | -0.93 | > .999
#> A M - A H |       -0.56 | 5.16 | [-10.93,  9.81] | -0.11 | > .999
#> A M - B H |        5.22 | 5.16 | [ -5.15, 15.59] |  1.01 | > .999
#> B M - A H |        4.22 | 5.16 | [ -6.15, 14.59] |  0.82 | > .999
#> B M - B H |       10.00 | 5.16 | [ -0.37, 20.37] |  1.94 | 0.822 
#> A H - B H |        5.78 | 5.16 | [ -4.59, 16.15] |  1.12 | 0.998 
#> 
#> p-value adjustment method: Tukey

Created on 2025-05-08 with reprex v2.1.1


It looks like we have a huge internal .p_adjust() function that is trying to apply all these corrections, accounting for emmeans's by-variables, etc... why aren't we simply extracting the p-values given by emmeans? It seems (in model_parameters.emmGrid()) that we are going out of our way to unadjusted and re-adjust p-values...

Is there any objection to relying on the values given by emmeans?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions