How do I find the upper and lower critical values of an F-test: var.test(x,y)
Example from my text:
x <- c (1973, 403, 509, 2103, 1153 292, 1916, 1602, 1559, 547, 801, 359)
y <- c (1185, 885, 2955, 815, 2852, 1217, 1762, 2592, 1632)
var.test(x,y, alternative = c("two.sided"), conf.level = 0.95)
F test to compare two variances
data: x and y
F = 0.6908, num df = 11, denom df = 8, p-value = 0.5572
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.1628029 2.5311116
sample estimates:
ratio of variances
0.6908397
Book says that the critical values are F < 0.273 and F > 4.30
Seems like R says F < 0.1628029 and F > 2.5311116
Any ideas on this one?
The 95% confidence interval is on the ratio of the variances, not on the F statistic. Here's the F statistic calculation:
> qf(c(0.025,0.975),11,8)
[1] 0.2729392 4.2434128
which agrees with your table.
If we look inside stats:::var.test.default
we find
BETA <- (1 - conf.level)/2
CINT <- c(ESTIMATE/qf(1 - BETA, DF.x, DF.y), ESTIMATE/qf(BETA,
DF.x, DF.y))
The second line could actually be written slightly more simply as ESTIMATE/qf(c(1-BETA,BETA),DF.x,DF.y)
, but I'm not sure this kind of trivial code cleanup is worth the effort of suggesting to R-core ...
Doing this calculation with conf.level
equal to 0.95, the variance ratio estimate from above, and the quantiles we computed above matches up:
> 0.6908397/c(0.273,4.30)
[1] 2.5305484 0.1606604