R F-test Example


var.test() function performs F-test between 2 normal populations with hypothesis that variances of the 2 populations are equal.

var.test(x, ...)
var.test(x, y, ratio = 1, alternative = c("two.sided", "less", "greater"),
conf.level = 0.95, ...)


x,y: Normally distributed data sets
ratio: Hypothesized ratio of x/y, default is 1
alternative: alternative hypothesis, including "two.sided","greater","less"
conf.level: confidence level

> x <- rnorm(100, mean=0)
> y <- rnorm(100, mean=1)
> var.test(x,y)

F test to compare two variances
data: x and y
F = 0.8795, num df = 99, denom df = 99, p-value = 0.5242
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.5917706 1.3071567
sample estimates:
ratio of variances
0.8795095


Since the p-value = 0.5242, which is much higher than 0.05, the hypothesis that the variances of x and y are equal is accepted.