简体   繁体   English

R中的Levene事后测试

[英]Levene post hoc test in R

I have a problem regarding my data analysis in R. One of my hypothesis is basically that my groups will differ in terms of spread of the scores, indicating that there would be a difference in extremity between the groups. 我在R中进行数据分析时遇到了一个问题。我的一个假设基本上是,我的组在分数分布上会有所不同,这表明各组之间的肢体会有差异。

I decided to check my hypothesis with Levenes test, which turned out significant and should thus highlight that the standard deviations is significantly different between the groups. 我决定用Levenes检验来检验我的假设,事实证明该假设很重要,因此应强调各组之间的标准差存在显着差异。 But I do not know of any post hoc tests for Levenes test, and after reading up on possible post hoc analyses I decided to conduct an ANOVA on the residuals, and then do a post hoc test on the ANOVA. 但是我不知道Levenes检验的任何事后检验,在阅读了可能的事后分析后,我决定对残差进行ANOVA,然后对ANOVA进行事后检验。

This is the code I've tried so far: 到目前为止,这是我尝试过的代码:

leveneTest(SS_mean~RA01, DF)
DF$residuals <- abs(DF$SS_mean - DF$SS_mean_big) #SS_mean = Participants score, 
#SS_mean_big = mean for each group.

My test and post hoc test looks like this: 我的测试和事后测试看起来像这样:

levene.anova<-aov(residuals~RA01, DF) #RA01 is the groups. Four in total
summary(levene.anova)
TukeyHSD(levene.anova)

The ANOVA on the residuals turned out significant as well, but the p-value changed from 0.04 (Levenes test) to 0.01 (ANOVA on residuals). 残差的ANOVA也很明显,但是p值从0.04(Levenes检验)变为0.01(残差的ANOVA)。 When reading about it, it seemed like Levene test is just an ANOVA on the resiudals, and thus it should give me the same results. 当阅读它时,Levene检验似乎只是对残渣的方差分析,因此它应该给我相同的结果。 And I am also unsure what post hoc test i should use. 而且我也不确定我应该使用哪种事后测试。 I thought about Dunnett as well as it includes a baseline, which corresponds to one of my groups. 我考虑了Dunnett并考虑了一个基线,该基线对应于我的一个小组。

Lastly, I did a leveneTest on the residuals as well "leveneTest(residuals~RA01)", which turned out significant. 最后,我还对残差进行了leveneTest以及“ leveneTest(residuals〜RA01)”,结果很有意义。 Is it better for me to use a non-parametric test, eg Kruskal-Wallis h-test and conduct a post hoc test on my kruskal wallis test instead? 对我来说,使用非参数检验(例如Kruskal-Wallis h检验)对我的kruskal wallis检验进行事后检验是否更好? And if this is the case, what would be the appropriate test? 如果是这种情况,什么是适当的测试? Should I use a pairwise Mann Whitney u-test or Dunn test? 我应该使用成对的Mann Whitney u检验还是Dunn检验?

As this is the first time im doing something like this, I'm unsure about if this is a legitimate analysis, I would really appreciate your help or input! 由于这是我第一次这样做,因此我不确定这是否是合法的分析,非常感谢您的帮助或投入!

Levene's test should indeed give the same p-value as an ANOVA on the residuals. 对于残差,Levene检验的确应提供与方差分析相同的p值。

See for example this code: 例如参见以下代码:

data("mtcars")
mtcars$cyl <- as.factor(mtcars$cyl)

# Calculate means and add them to data
cyl_means <- aggregate(disp ~ cyl, data = mtcars, FUN = mean)
colnames(cyl_means)[2] <- "disp_mean"
mtcars2 <- merge(mtcars, cyl_means, by = "cyl")

# Residuals and anova
mtcars2$residuals <- abs(mtcars2$disp - mtcars2$disp_mean)
res.aov <- aov(residuals ~ cyl, data = mtcars2)
summary(res.aov)

# Levene's test
lawstat::levene.test(mtcars$disp, mtcars$cyl, location = "mean")

Maybe you accidentially ran the Brown–Forsythe test instead, which is the default in lawstat::levene.test , and which uses the median instead of the mean to calculate residuals. 也许您不小心运行了Brown–Forsythe测试,这是lawstat::levene.test的默认设置,并且使用中位数而不是均值来计算残差。

Use Dunnett's if you are only interested in comparing the groups to one baseline group. 如果您只想将组与一个基准组进行比较,请使用Dunnett。 Use TukeyHSD if you want all pairwise comparisons among groups. 如果要在组之间进行所有成对比较,请使用TukeyHSD。

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

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