Learn R Programming

DMAR (version 1.0.0)

obrien_test: O'Brien's Test for Homogeneity of Variance

Description

Tests the null hypothesis that two or more groups have equal population variances using O'Brien's (1981) procedure: each observation is transformed into a quantity whose expected value equals the group's variance, and a one-way analysis of variance is then run on those transformed values. The test is generally regarded as more robust to non-normality than Bartlett's test while retaining good power.

Usage

obrien_test(x, group = NULL, data = NULL, na_action = stats::na.omit)

Value

A one-row data.frame with columns statistic (the

F-value from the ANOVA on the transformed scores), df_1,

df_2, p_value, n_groups, n_total, and

method.

Arguments

x

Either a numeric vector of observations (in which case group must also be supplied), or a one-sided formula of the form y ~ group, in which case data is consulted for the variables.

group

A grouping vector or factor of the same length as x; used only when x is a numeric vector.

data

An optional data.frame containing the variables named in the formula.

na_action

Function specifying how missing values are handled (default na.omit).

Author

Ken Kelley [email protected]

Details

Following O'Brien (1981) and the version given in Abdi (2007), each observation \(Y_{ij}\) (the \(j\)th observation in group \(i\), with size \(n_i\) and sample variance \(s_i^2\)) is transformed to $$r_{ij} = \frac{(n_i - 1.5)\, n_i\, (Y_{ij} - \bar{Y}_i)^2 - 0.5\, s_i^2\, (n_i - 1)}{(n_i - 1)(n_i - 2)}.$$ The mean of the \(r_{ij}\) within group \(i\) equals \(s_i^2\), so a one-way ANOVA on the \(r_{ij}\) tests \(H_0\!: \sigma_1^2 = \cdots = \sigma_k^2\). Each group must have at least three observations for the transformation to be defined.

References

Abdi, H. (2007). O'Brien's test for homogeneity of variance. In N. J. Salkind (Ed.), Encyclopedia of measurement and statistics. Sage.

O'Brien, R. G. (1981). A simple test for variance effects in experimental designs. Psychological Bulletin, 89(3), 570--574.

See Also

bartlett.test, var.test

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

Examples

Run this code
# Hunter's (1964) "one-is-a-bun" peg-word memory experiment, as discussed
# by Abdi (2007). Sixty-four participants were assigned to a control group
# (no mnemonic instruction) or an experimental group (peg-word mnemonic).
# The score is the number of word pairs (out of 10) recalled. Abdi (2007,
# Table 6) reports F = 1.29 (df = 1, 62) for the O'Brien test of equal
# variances, p = .260 as computed here; the experimental group's apparent
# ceiling effect does not produce statistically detectable variance
# heterogeneity.
hunter_1964 <- data.frame(
  group = factor(
    c(rep("Control", 32), rep("Experimental", 32)),
    levels = c("Control", "Experimental")
  ),
  recall = c(
    # Control group (n = 32):
    5, 5, 5, 5, 5,
    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
    7, 7, 7, 7, 7, 7, 7, 7, 7,
    8, 8, 8,
    9, 9,
    10, 10,
    # Experimental group (n = 32):
    6,
    7, 7,
    8, 8, 8, 8,
    9, 9, 9, 9, 9, 9, 9, 9, 9,
    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
  )
)
obrien_test(recall ~ group, data = hunter_1964)

# Comparison against Bartlett's test on the same data.
bartlett.test(recall ~ group, data = hunter_1964)

# Vector / grouping-variable interface, on DMAR's depression_bdi data.
# The wait list variance is about twice the SSRI variance, but with ten
# observations per group the test does not reject equal variances.
obrien_test(depression_bdi$bdi_post, depression_bdi$condition)

Run the code above in your browser using DataLab