Skip to content

Conversation

@strengejacke
Copy link
Member

Fixes #1101

@strengejacke
Copy link
Member Author

I reverted the change for re-computing the ANOVA, because it returned wrong p-values?

data(laptop_urry, package = "afex")
afx <- afex::aov_4(
  overall ~ condition * talk + (1 | pid),
  data = laptop_urry,
  anova_table = list(p_adjust_method = "bonferroni")
)
#> Contrasts set to contr.sum for the following variables: condition, talk

afx
#> Anova Table (Type 3 tests, bonferroni-adjusted)
#> 
#> Response: overall
#>           Effect     df    MSE        F  ges p.value
#> 1      condition 1, 132 220.46     0.52 .004   >.999
#> 2           talk 4, 132 220.46 7.60 *** .187   <.001
#> 3 condition:talk 4, 132 220.46     2.20 .063    .216
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
anova(afx)
#> Anova Table (Type 3 tests, bonferroni-adjusted)
#> 
#> Response: overall
#>                num Df den Df    MSE      F      ges    Pr(>F)    
#> condition           1    132 220.46 0.5217 0.003937    1.0000    
#> talk                4    132 220.46 7.6018 0.187229 4.579e-05 ***
#> condition:talk      4    132 220.46 2.2045 0.062619    0.2157    
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

afex::aov_4(
  overall ~ condition * talk + (1 | pid),
  data = laptop_urry
)
#> Contrasts set to contr.sum for the following variables: condition, talk
#> Anova Table (Type 3 tests)
#> 
#> Response: overall
#>           Effect     df    MSE        F  ges p.value
#> 1      condition 1, 132 220.46     0.52 .004    .471
#> 2           talk 4, 132 220.46 7.60 *** .187   <.001
#> 3 condition:talk 4, 132 220.46   2.20 + .063    .072
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1

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

@strengejacke
Copy link
Member Author

I'm not sure why we extract model$anova_table in one case, and model$Anova in the other case, but the first returns adjusted p-values, the latter not. I fixed the code, so p-adjustment is only applied to the latter case. Should be correct now.

@strengejacke strengejacke merged commit d544ba3 into main May 8, 2025
18 of 23 checks passed
@strengejacke strengejacke deleted the strengejacke/issue1101 branch May 8, 2025 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adjusted p values from afex::aov_4() not retained by model_parameters()

3 participants