我有两个样本,我有手段(sd)和大小。
i.e.
6.27 +/- 5.9 (size 34)
5.91 +/- 4.9 (size 6)
如何连接两个样本并获得平均值和 SD?
提前 TY。
我有两个样本,我有手段(sd)和大小。
i.e.
6.27 +/- 5.9 (size 34)
5.91 +/- 4.9 (size 6)
如何连接两个样本并获得平均值和 SD?
提前 TY。
这是一种方法:
mean_1 <- 6.27
sd_1 <- 5.9
mean_2 <- 5.91
sd_2 <- 4.9
n_1 <- 34
n_2 <- 6
# the combined mean
mean_combined <- weighted.mean(c(mean_1, mean_2), c(n_1, n_2))
# [1] 6.216
# the combined standard deviation (if the samples are not correlated)
sd_combined <- sqrt(sd_1^2 + sd_2^2)
# [1] 7.66942
# the pooled standard deviation
# (under the assumption that both samples are from the same population)
sd_pooled <- sqrt((n_1 * sd_1^2 + n_2 * sd_2^2 +
n_1 * (mean_1 - mean_combined) +
n_2 * (mean_2 - mean_combined)) / (n_1 + n_2))
# [1] 5.761076