modelbased icon indicating copy to clipboard operation
modelbased copied to clipboard

adjust argument in ``` estimate_contrasts() ``` is ignored when calculating p-values

Open docbio78 opened this issue 4 years ago • 0 comments

It seems there is a bug in estimate_contrasts as the p-values do not change when changing the adjustment method. There will be always Tukey-adjusted p-values be reported although the comment in the output says otherwise. See for comparison the same output with emmeans. There p-values are different between "tukey" or "fdr".

data <- iris
data$Petal.Length_factor <- ifelse(data$Petal.Length < 4.2, "A", "B")
model <- lmer(Sepal.Width ~ Species + (1 | Petal.Length_factor), data = data)

estimate_contrasts(model = model,
+                           lmer.df = "satterthwaite",
+                           adjust = "tukey")
No variable was specified for contrast estimation. Selecting `contrast = "Species"`.
Marginal Contrasts Analysis

Level1     |     Level2 | Difference |        95% CI |   SE |     df |     t |      p
-------------------------------------------------------------------------------------
setosa     | versicolor |       0.87 | [ 0.67, 1.07] | 0.09 | 135.61 | 10.11 | < .001
setosa     |  virginica |       0.80 | [ 0.53, 1.06] | 0.11 | 118.54 |  7.11 | < .001
versicolor |  virginica |      -0.07 | [-0.25, 0.10] | 0.07 | 145.27 | -1.00 | 0.578 

Marginal contrasts estimated at Species
p-value adjustment method: Tukey

> estimate_contrasts(model = model,
+                    lmer.df = "satterthwaite",
+                    adjust = "fdr")
No variable was specified for contrast estimation. Selecting `contrast = "Species"`.
Marginal Contrasts Analysis

Level1     |     Level2 | Difference |        95% CI |   SE |     df |     t |      p
-------------------------------------------------------------------------------------
setosa     | versicolor |       0.87 | [ 0.66, 1.08] | 0.09 | 135.61 | 10.11 | < .001
setosa     |  virginica |       0.80 | [ 0.53, 1.07] | 0.11 | 118.54 |  7.11 | < .001
versicolor |  virginica |      -0.07 | [-0.25, 0.10] | 0.07 | 145.27 | -1.00 | 0.578 

Marginal contrasts estimated at Species
p-value adjustment method: Benjamini & Hochberg (1995)

> # compare to emmeans
> emmeans(model,
+         pairwise ~ Species,
+         lmer.df = "satterthwaite",
+         adjust = "tukey")
$emmeans
 Species    emmean    SE   df lower.CL upper.CL
 setosa       3.60 0.189 1.11    1.692     5.51
 versicolor   2.73 0.184 1.00    0.388     5.07
 virginica    2.80 0.189 1.11    0.894     4.71

Degrees-of-freedom method: satterthwaite 
Confidence level used: 0.95 

$contrasts
 contrast               estimate     SE  df t.ratio p.value
 setosa - versicolor      0.8708 0.0861 136 10.110  <.0001 
 setosa - virginica       0.7973 0.1121 119  7.115  <.0001 
 versicolor - virginica  -0.0736 0.0736 145 -1.000  0.5783 

Degrees-of-freedom method: satterthwaite 
P value adjustment: tukey method for comparing a family of 3 estimates 

> emmeans(model,
+         pairwise ~ Species,
+         lmer.df = "satterthwaite",
+         adjust = "fdr")
$emmeans
 Species    emmean    SE   df lower.CL upper.CL
 setosa       3.60 0.189 1.11    1.692     5.51
 versicolor   2.73 0.184 1.00    0.388     5.07
 virginica    2.80 0.189 1.11    0.894     4.71

Degrees-of-freedom method: satterthwaite 
Confidence level used: 0.95 

$contrasts
 contrast               estimate     SE  df t.ratio p.value
 setosa - versicolor      0.8708 0.0861 136 10.110  <.0001 
 setosa - virginica       0.7973 0.1121 119  7.115  <.0001 
 versicolor - virginica  -0.0736 0.0736 145 -1.000  0.3192 

Degrees-of-freedom method: satterthwaite 
P value adjustment: fdr method for 3 tests 

Do I miss something or this a bug in estimate_contrasts ?

Thx Stefan

docbio78 avatar Nov 23 '21 17:11 docbio78