I am trying to understand where the p-value of a F-test comparing two variances comes from. More specifically, the p-value given by R's var.test
function does not match p-value assigned to a F-test by the pf
function with the same F value and degrees of freedom.
For example, p-value given here:
> d1 <- rnorm(300, sd=1)
> d2 <- rnorm(300, sd=1.2)
> var.test(d1, d2)
F test to compare two variances
data: d1 and d2
F = 0.78, num df = 299, denom df = 299, p-value = 0.03212
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.62 0.98
sample estimates:
ratio of variances
0.78
Does not match this one:
> pf(0.78, 299, 299, lower.tail=F)
[1] 0.98
Could someone explain where the difference comes from?