# Maxwell, Delaney, & Kelley (2027) offer an example that 30 depressive
# individuals are randomly assigned to three groups, 10 in each, and ANCOVA
# is performed on the posttest scores using the participants' pretest
# scores as the covariate. The means of pretest scores of group 1, 2, and 3 are
# 17, 17.7, and 17.4, respectively, whereas the adjusted means of groups 1, 2, and 3
# are 7.5, 12, and 14, respectively. The error variance in ANCOVA is 29 and thus
# 5.385165 is the error standard deviation, with the sum of squares within groups
# from an ANOVA on the covariate is 752.5.
# To obtained the confidence interval for the standardized adjusted mean difference
# between group 1 and 2, using the ANCOVA error standard deviation:
ci_sc_ancova(adj_means = c(7.5, 12, 14), s_ancova = 5.385165, c_weights = c(1, -1, 0),
n = 10, cov_means = c(17, 17.7, 17.4), SSwithin_x = 752.5)
# Or, with less error in rounding:
ci_sc_ancova(adj_means = c(7.54, 11.98, 13.98), s_ancova = 5.393, c_weights = c(-1, 0, 1),
n = 10, cov_means = c(17, 17.7, 17.4), SSwithin_x = 752.5)
# Now, using the standard deviation from ANOVA (and not ANCOVA as above), we have:
ci_sc_ancova(adj_means = c(7.54, 11.98, 13.98), s_anova = 6.294, s_ancova = 5.393,
c_weights = c(-1, 0, 1),n = 10, cov_means = c(17, 17.7, 17.4),
SSwithin_x = 752.5, standardizer = "s_anova", conf_level = .95)
# Recovering SSwithin_x from a covariate ANOVA F when a report does not print
# it directly (see the Details section). This example follows Lai and Kelley
# (2012): three groups of sizes 19, 18, and 19 have covariate means 60.08,
# 57.08, and 57.97, and the one-way ANOVA on the covariate reports F = 0.756.
cov_means_ex <- c(60.08, 57.08, 57.97)
n_ex <- c(19, 18, 19)
grand_x <- sum(n_ex * cov_means_ex) / sum(n_ex)
ss_between_x <- sum(n_ex * (cov_means_ex - grand_x)^2)
ms_between_x <- ss_between_x / (length(n_ex) - 1)
ms_within_x <- ms_between_x / 0.756
SSwithin_x_ex <- ms_within_x * (sum(n_ex) - length(n_ex))
ci_sc_ancova(adj_means = c(63.88, 62.39, 56.48), s_ancova = 20.267,
c_weights = c(0.5, 0.5, -1), n = n_ex, cov_means = cov_means_ex,
SSwithin_x = SSwithin_x_ex)
Run the code above in your browser using DataLab