简体   繁体   English

尽管设置 effect.size = 'ges',rstatix package anova_test function 给出了部分 eta 平方

[英]rstatix package anova_test function gives partial eta squared despite setting effect.size = 'ges'

I am not able to obtain eta squared, only partial eta squared, when I use rstatix::anova_test .当我使用rstatix::anova_test时,我无法获得 eta 平方,只能获得部分 eta 平方。

Example from the iris dataset:来自 iris 数据集的示例:

First using aov :首先使用aov

aov <- aov(Sepal.Length ~ Sepal.Width + Species, data = iris)
summary(aov)
             Df Sum Sq Mean Sq F value  Pr(>F)    
Sepal.Width   1   1.41    1.41   7.363 0.00746 ** 
Species       2  72.75   36.38 189.651 < 2e-16 ***
Residuals   146  28.00    0.19      

Then using sjstats::eta_sq , if I choose partial = TRUE or FALSE I get a different effect size, as I would expect.然后使用sjstats::eta_sq ,如果我选择partial = TRUEFALSE ,我会得到不同的效果大小,如我所料。

eta_sq(aov, partial = FALSE) 
         term etasq
1 Sepal.Width 0.014
2     Species 0.712

eta_sq(aov, partial = TRUE)
         term partial.etasq
1 Sepal.Width         0.048
2     Species         0.722

However, when I do the same in anova_test , I get the partial eta squared both times regardless of whether the effect size is pes or ges, both times it's the partial eta squared:但是,当我在 anova_test 中执行相同操作时,无论效果大小是 pes 还是anova_test ,我都会得到部分 eta 平方,这两次都是部分 eta 平方:

aov_pes <- iris %>% anova_test(Sepal.Length ~ Sepal.Width + Species,
                               detailed = T,
                               effect.size = "pes")
get_anova_table(aov_pes)

       Effect    SSn    SSd DFn DFd       F        p p<.05
1 Sepal.Width 10.953 28.004   1 146  57.102 4.19e-12     *
2     Species 72.752 28.004   2 146 189.651 2.56e-41     *
    pes
1 0.281
2 0.722

aov_ges <- iris %>% anova_test(Sepal.Length ~ Sepal.Width + Species,
                               detailed = T,
                               effect.size = "ges")
get_anova_table(aov_ges)

       Effect    SSn    SSd DFn DFd       F        p p<.05
1 Sepal.Width 10.953 28.004   1 146  57.102 4.19e-12     *
2     Species 72.752 28.004   2 146 189.651 2.56e-41     *
    ges
1 0.281
2 0.722

Does anyone know why this is?有人知道为什么吗? Thanks!谢谢!

Answer回答

rstatix::anova_test seems to contain a mistake in the calculation, I would be very. rstatix::anova_test似乎包含计算错误,我会非常。 very careful with this function.非常小心这个功能。

Note that eta_sq is deprecated, and effectsize::eta_squared should be used.请注意,不推荐使用eta_sq ,应使用effectsize::eta_squared


Proper calculation正确计算

We have three SS values: 1.412238, 72.752431, and 28.003665.我们有三个 SS 值:1.412238、72.752431 和 28.003665。 We can calculate the pes and ges:我们可以计算 pes 和 ges:

  • pes: 1.412238 / (1.412238 + 28.003665) pes: 1.412238 / (1.412238 + 28.003665)
  • ges: 1.412238 / (1.412238 + 72.752431 + 28.003665) ges: 1.412238 / (1.412238 + 72.752431 + 28.003665)

anova_test方差分析

Under the hood, anova_test calls two functions for pes and ges calculation:在后台, anova_test调用了两个函数进行 pes 和 ges 计算:

  • pes: rstatix:::add_partial_eta_squared pes: rstatix:::add_partial_eta_squared
  • ges: rstatix:::add_generalized_eta_squared ges: rstatix:::add_generalized_eta_squared

The pes calculation by anova_test anova_test的 pes 计算

res.anova.summary$ANOVA %>% mutate(pes = .data$SSn/(.data$SSn + .data$SSd))

This indeed calculates the pes as we expect it to.这确实按照我们的预期计算了 pes。


The ges calculation by anova_test anova_test 的anova_test计算

aov.table <- res.anova.summary$ANOVA
aov.table %>% mutate(ges = .data$SSn/(.data$SSn + sum(unique(.data$SSd)) + obs.SSn1 - obs.SSn2))

Here, we run into a problem.在这里,我们遇到了一个问题。 This code seems blatantly incorrect.这段代码似乎明显不正确。 It just divides each sum of square value by itself + the residual sum of squares (28.004).它只是将每个平方和除以自身 + 剩余平方和 (28.004)。 That is the pes, not the ges.那是pes,不是ges。

You could contact the maintainer of the package ( maintainer("rstatix") ) or create a new issue for the rstatix package here .您可以联系 package 的维护者( maintainer("rstatix") )或在此处rstatix package 创建一个新问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM