我正在尝试计算R中功效分析的效果大小。每个数据点都是一个独立的样本均值。
data <- c(621.4, 621.4, 646.8, 616.4, 601.0, 600.2, 616.1, 613.4, 616.5, 624.3, 608.3, 624.2)
data.sd <- sd(data)
# effect size for a difference of means of 3
d <- 3 / data.sd
# sample size required
require(pwr)
pwr.t.test(d = d, power = 0.80, sig.level = 0.05, type = "two.sample", alternative = "two.sided")
我是否正确计算了效果大小?或者我应该将3的平均差除以标准误差?
d <- 3 / (data.sd / sqrt(length(data)))
答案 0 :(得分:1)
也可以在预先安装的 stats 包中执行功效分析(至少对于t检验):
> power.t.test(delta=3, sd=sd(data), sig.level=.05, power=.8)
Two-sample t test power calculation
n = 263.7348
delta = 3
sd = 12.27414
sig.level = 0.05
power = 0.8
alternative = two.sided
NOTE: n is number in *each* group
文档很清楚:
n Number of observations (per group)
delta True difference in means
sd Standard deviation
sig.level Significance level (Type I error probability)
power Power of test (1 minus Type II error probability)
这只是平均差和标准差;不是科恩的 d 或SE。