有没有人能帮我理解一下如何从具有对比度的方差分析中计算出cohen's D?从向量或数据集计算cohen's D没有问题,但我不能从对比中找出如何计算。谢谢。
#Create data frame
group = c("treatment","treatment","treatment","treatment","treatment","treatment","treatment","treatment","treatment","treatment",
"control","control","control","control","control","control","control","control","control","control",
"other","other","other","other","other","other","other","other","other","other")
score = c(7,8,9,10,7,8,9,10,7,8,
6,5,4,6,5,4,6,5,4,6,
3,2,1,3,2,1,3,2,1,3)
sample =data.frame(group,score)
#Set contrasts
contrast = c(-1,0,1)
#Bind contrasts
contrasts(sample$group) = cbind(contrast)
#Check contrasts
contrasts(sample$group)
#Run ANOVA w/ contrasts
aov1 = aov(score ~ group, sample)
summary.lm(aov1)发布于 2020-05-19 09:37:03
计算科恩的D的函数至少在三个不同的R包中,包括effsize、rstatix和psych包。在aov()函数中没有专门用来计算科恩D的特性。
Cohen的D需要一个二分群变量。给定OP中的数据以及比较测试组和控制组的对比语句,我们将使用psych::cohen.d()比较测试组和控制组。
group = c("treatment","treatment","treatment","treatment","treatment","treatment","treatment","treatment","treatment","treatment",
"control","control","control","control","control","control","control","control","control","control",
"other","other","other","other","other","other","other","other","other","other")
score = c(7,8,9,10,7,8,9,10,7,8,
6,5,4,6,5,4,6,5,4,6,
3,2,1,3,2,1,3,2,1,3)
sample =data.frame(group,score)
sample2 <- sample[sample$group != "other",]
sample2$group <- factor(sample2$group)
library(psych)
cohen.d(score ~ group, data = sample2)对输出执行...and操作:
> cohen.d(score ~ group, data = sample2)
Cohen's d
d estimate: -3.114651 (large)
95 percent confidence interval:
lower upper
-4.512240 -1.717062 https://stackoverflow.com/questions/61880546
复制相似问题