Calculates the standard error for the difference in means between two groups
se_diff_means(data, var, by)
A data frame
A numeric variable containing the data for the calculation of the means
A grouping variable with only two values
A numeric value for the difference in means
data(sleep)
sleep$group <- as.numeric(sleep$group)
se_diff_means(data = sleep, var = "extra", by = "group")
#> [1] 0.849091
# confirming against Kirkwood and Sterne
dat <- data.frame(weight = c(3.18, 2.74, 2.90, 3.27, 3.65, 3.42, 3.23, 2.86,
3.6, 3.65, 3.69, 3.53, 2.38, 2.34, 3.99, 3.89,
3.60, 3.73, 3.31, 3.7, 4.08, 3.61, 3.83, 3.41,
4.13, 3.36, 3.54, 3.51, 2.71),
group = c(rep(1, 14), rep(0, 15)))
se_diff_means(data = dat, var = "weight", by = "group")
#> [1] 0.1545482