Learn R Programming

DMAR (version 1.0.0)

ci_tukey_kramer: Tukey-Kramer Simultaneous Confidence Intervals for Pairwise Contrasts

Description

Computes the Tukey-Kramer simultaneous confidence intervals for all \(a (a - 1) / 2\) pairwise contrasts among \(a\) group means in a one-way design with possibly unequal group sample sizes (Tukey, 1953; Kramer, 1956; Hayter, 1984), and returns the result in tidy long form. Each interval has individual coverage at least the specified conf_level and the family-wise coverage is at least conf_level.

Usage

ci_tukey_kramer(x, group = NULL, conf_level = 0.95)

Value

A data.frame with one row per pairwise contrast. Columns: contrast (e.g., "B - A"),

mean_difference, se, q_statistic

(the studentized-range \(q\)), lower_limit,

upper_limit, p_adjusted.

Arguments

x

Either (a) a fitted lm or aov object with a single one-way factor predictor, or (b) a numeric vector of observations, in which case group must also be supplied.

group

When x is a vector, a factor (or coercible to factor) of group labels, same length as x.

conf_level

Family-wise confidence level. Default 0.95.

Author

Ken Kelley [email protected]

Details

Formula. For groups \(i, j\) with means \(\bar y_i, \bar y_j\) and sample sizes \(n_i, n_j\), the Tukey-Kramer simultaneous CI is $$\bar y_i - \bar y_j \;\pm\; q_{\alpha, a, \nu} \sqrt{\frac{\mathit{MS}_E}{2} \left(\frac{1}{n_i} + \frac{1}{n_j}\right)},$$ where \(q_{\alpha, a, \nu}\) is the upper \(\alpha\) quantile of the studentized-range distribution with \(a\) groups and \(\nu\) error degrees of freedom (stats::qtukey()).

Why Tukey-Kramer. Hayter (1984) proved that the Tukey-Kramer procedure is conservative for unbalanced designs (the coverage probability is at least conf_level). For balanced designs it reduces to Tukey's HSD and the coverage is exactly conf_level.

Adjusted p-values. Each pairwise \(p\)-value is computed from the studentized-range distribution: \(p = 1 - \mathrm{ptukey}(|q|, a, \nu)\).

References

Hayter, A. J. (1984). A proof of the conjecture that the Tukey-Kramer multiple comparisons procedure is conservative. Annals of Statistics, 12(1), 61--75.

Kramer, C. Y. (1956). Extension of multiple range tests to group means with unequal numbers of replications. Biometrics, 12(3), 307--310.

Tukey, J. W. (1953). The problem of multiple comparisons. Unpublished manuscript, Princeton University.

See Also

cv_tukey_hsd, ci_dunnett, ci_scheffe, TukeyHSD

Other hypothesis tests: adjusted_means(), ancova(), anova_within(), ci_dunnett(), ci_scheffe(), compare_cov_structures(), contrast_test(), correlations_test(), equivalence_r(), equivalence_smd(), factorial_anova(), manova_split_plot(), mauchly_test(), mixed_anova(), obrien_test(), pairwise_within(), randomization_test(), randomization_test_paired(), regions_of_significance(), simple_effects_AB(), summary_t_test(), welch_t()

Examples

Run this code
# 1. Balanced one-way: the six marketing panels of the test_market
#    data, four outlets per panel, so the procedure is exactly Tukey's
#    HSD. Panels 5 and 6 separate from panel 1.
fit <- lm(brand_movement ~ panel, data = test_market)
ci_tukey_kramer(fit)

# 2. Same data via vector / group interface:
ci_tukey_kramer(test_market$brand_movement, group = test_market$panel)

Run the code above in your browser using DataLab