Skip to content

Perform Hartley's Fmax test

Source: man/performHartleyFmaxTest.Rd · Help: ?performHartleyFmaxTest

Compares the maximum and minimum group residual variances using Hartley's maximum F-ratio distribution.

Usage

performHartleyFmaxTest(model, data = NULL, group)

Arguments

model
A fitted lm object.
data
Data frame used to fit model. When NULL, the default, the model frame of model is used, so group must then be a variable of the model. The model frame holds the terms of the model rather than its variables (log(x) rather than x), so a model that transforms a variable needs data, as does a model with an offset() term.
group
Name of the grouping variable.

Value

An object of class htest containing the Fmax statistic, number of groups, reference degrees of freedom and p-value.

Details

The statistic is \(F_{max}=\max_j s_j^2/\min_j s_j^2\). Under normality and equal group sizes its null distribution is the maximum F-ratio distribution for \(k\) independent mean squares with common degrees of freedom, evaluated with SuppDists::pmaxFratio(). If group sizes differ, the function warns and rounds the mean group size, then subtracts one, to obtain an approximate common integer degrees of freedom.

References

Hartley, H. O. (1950). The maximum F-ratio as a short-cut test for heterogeneity of variance. Biometrika, 37(3/4), 308–312.

Examples

 set.seed(1701)
 n <- 20
 d <- data.frame(g = factor(rep(letters[1:3], each = n)), x = rnorm(3 * n))
 d$y <- 1 + d$x + rnorm(3 * n)
 m <- lm(y ~ x, data = d)
 performHartleyFmaxTest(m, d, "g")