A variance ratio test is used to test whether or not two population variances are equal.
This test uses the following null and alternative hypotheses:
- H0: The population variances are equal
- HA: The population variances are not equal
To perform this test, we calculate the following test statistic:
F = s12 / s22
where:
- s12: The sample variance of the first group
- s22: The sample variance of the second group
If the p-value that corresponds to this F test-statistic is less than a certain threshold (e.g. 0.05) then we reject the null hypothesis and conclude that the population variance are not equal.
To perform a variance ratio test in R, we can use the built-in var.test() function.
The following example shows how to use this function in practice.
Example: Variance Ratio Test in R
Suppose we want to know if two different species of plants have the same variance in height.
To test this, we collect a simple random sample of 15 plants from each species.
The following code shows how to perform a variance ratio test in R to determine if the variance in height is equal between the two species:
#create vectors to hold plant heights from each sample group1 #perform variance ratio test var.test(group1, group2) F test to compare two variances data: group1 and group2 F = 0.43718, num df = 14, denom df = 14, p-value = 0.1336 alternative hypothesis: true ratio of variances is not equal to 1 95 percent confidence interval: 0.1467737 1.3021737 sample estimates: ratio of variances 0.4371783
Here’s how to interpret the results of the test:
data: The names of the vectors that contain the sample data.
F: The F test-statistic. In this case, it is 0.43718.
num df, denom df: The degrees of freedom numerator and denominator for the F test-statistic, calculated as n1 – 1 and n2-1, respectively.
p-value: The p-value that corresponds to the F test-statistic of 0.43718 with numerator df = 14 and denominator df = 14. The p-value turns out to be .1336.
95 percent confidence interval: The 95% confidence interval for the true ratio of variances between the two groups. It turns out to be [.147, 1.302]. Since 1 is contained in this interval, it’s plausible for the true ratio of variances to be 1, i.e. equal variances.
sample estimates: This represents the ratio of variances between each group. If we use the var() function, we can find that the sample variance of the first group is 21.8381 and the sample variance of the second group is 49.95238 . Thus, the ratio of variances is 21.8381 / 49.95238 = 0.4371783.
Recall the null and alternative hypotheses for this test:
- H0: The population variances are equal
- HA: The population variances are not equal
Because the p-value of our test (.1336) is not less than 0.05, we fail to reject the null hypothesis.
This means we do not have sufficient evidence to conclude that the variance in plant height between the two species is unequal.
Additional Resources
The following tutorials explain how to perform other common tasks in R:
How to Perform a One Sample T-Test in R
How to Perform Welch’s T-Test in R
How to Perform a Paired Samples T-Test in R