【问题标题】:cohen's D with contrasts in R科恩的 D 与 R 中的对比
【发布时间】:2020-05-18 23:12:12
【问题描述】:

有人可以帮助我了解如何从具有对比的 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)

【问题讨论】:

    标签: r statistics statistical-test


    【解决方案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 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-10
      • 2012-11-04
      • 1970-01-01
      • 1970-01-01
      • 2023-01-14
      相关资源
      最近更新 更多