F (Variance Ratio) Test
Menu location: Analysis_Parametric_F (Variance Ratio).
This function tests the equality of the variances of two random samples from a normal distribution.
F is the ratio of variances (largest as numerator) from samples of size n1 and n2. Degrees of freedom are n1-1 and n2-1 corresponding to the numerator and denominator sample variances.
Only the upper tail probability need be considered because the larger variance is always used as the numerator in the variance ratio F (Altman, 1991; Armitage and Berry, 1994). For a two sided test the smaller of the two tail probabilities is doubled; with the larger variance on top that is usually the upper tail, but not always when the degrees of freedom differ. Analysis of variance can utilise a one sided probability because the numerator and denominator of the variance ratio are predetermined.
Example
Test workbook (Parametric worksheet: Slight/no symptoms, Marked symptoms).
Consider the following scores, on a scale of 0 to 100, from nine patients with slight or no symptoms and seven patients with marked symptoms (an illustration rather than a real study). The question is whether the scores vary more in one group than in the other.
| Slight/no symptoms | Marked symptoms |
|---|---|
| 34 | 5 |
| 45 | 8 |
| 49 | 18 |
| 55 | 24 |
| 58 | 60 |
| 59 | 84 |
| 60 | 96 |
| 62 | |
| 86 |
To analyse these data in StatsDirect open the test workbook using the file open function of the file menu. Then select F (Variance Ratio) from the Parametric section of the Analysis menu. Select the columns marked "Slight/no symptoms" and "Marked symptoms" when prompted for data.
For this example:
Variance ratio/F test
| Variable Name | DF (n-1) | Variance |
| Marked symptoms | 6 | 1404.809524 |
| Slight/no symptoms | 8 | 202.277778 |
F = 6.944952
Upper side P = 0.0077
Two sided P = 0.0153
The variance of the scores is nearly seven times larger in the patients with marked symptoms, and the two sided test is significant at the 5% level. The equal variances assumed by the ordinary unpaired t test would be doubtful for these data, so the unequal variances form of that test, or a nonparametric method, would be safer.
R code
This R code reproduces the example above. It needs no packages and was checked with R 4.6.1. Paste it into R, or save it as a script and run it.
# F (variance ratio) test: the StatsDirect help example (scores of patients with
# slight or no symptoms and with marked symptoms) in R
slight <- c(34, 45, 49, 55, 58, 59, 60, 62, 86)
marked <- c(5, 8, 18, 24, 60, 84, 96)
# R's standard test. Its F is the first sample's variance over the second's, so
# the sample with the larger variance goes first to get StatsDirect's F; its P is
# two sided.
f <- var.test(marked, slight)
print(f)
# The report's lines: each variance with its degrees of freedom, F, the upper
# tail P and its double, the two sided P
six <- function(x) formatC(x, digits = 6, format = "f", drop0trailing = TRUE)
cat("Marked symptoms DF =", length(marked) - 1, " Variance =", six(var(marked)),
"\n")
cat("Slight/no symptoms DF =", length(slight) - 1, " Variance =", six(var(slight)),
"\n")
cat("F =", six(f$statistic), "\n")
p <- pf(f$statistic, f$parameter[1], f$parameter[2], lower.tail = FALSE)
cat(sprintf("Upper side P = %.4f Two sided P = %.4f\n", p, 2 * min(p, 1 - p)))