0

有人可以帮助我了解如何从具有对比的 ANOVA 计算科恩的 D 吗?我从向量或数据集计算科恩的 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)
4

1 回答 1

1

计算 Cohen 的 D 的函数在至少三个不同的 R 包中,包括effsizerstatixpsych包。函数中没有专门aov()用于计算 Cohen 的 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)

...和输出:

> cohen.d(score ~ group, data = sample2)

Cohen's d

d estimate: -3.114651 (large)
95 percent confidence interval:
    lower     upper 
-4.512240 -1.717062 
于 2020-05-19T01:37:03.330 回答