# How to Create a Confidence Interval Using the F Distribution

To determine if the variances of two populations are equal, we can calculate the variance ratio σ21 / σ22, where σ21 is the variance of population 1 and σ22 is the variance of population 2.

To estimate the true population variance ratio, we typically take a simple random sample from each population and calculate the sample variance ratio, s12 / s22, where s12  and s22 are the sample variances for sample 1 and sample 2, respectively.

This test assumes that both s12  and s22 are computed from independent samples of size n1 and n2, both drawn from normally distributed populations.

The further this ratio is from one, the stronger the evidence for unequal population variances.

The (1-α)100% confidence interval for σ21 / σ22 is defined as:

(s12  / s22) * Fn1-1, n2-1, α/2   ≤  σ21 / σ22  ≤  (s12  / s22) * Fn2-1, n1-1, α/2

where Fn2-1, n1-1, α/2 and Fn1-1, n2-1, α/2 are the critical values from the F distribution for the chosen significance level α.

The following examples illustrate how to create a confidence interval for σ21 / σ22 using three different methods:

• By hand
• Using Microsoft Excel
• Using the statistical software R

For each of the following examples, we will use the following information:

• α = 0.05
• n1 = 16
• n2 = 11
• s12 =28.2
• s22 = 19.3

## Creating a Confidence Interval By Hand

To calculate a confidence interval for σ21 / σ22 by hand, we’ll simply plug in the numbers we have into the confidence interval formula:

(s12  / s22) * Fn1-1, n2-1,α/2   ≤  σ21 / σ22  ≤  (s12  / s22) * Fn2-1, n1-1, α/2

The only numbers we’re missing are the critical values. Luckily, we can locate these critical values in the F distribution table:

Fn2-1, n1-1, α/2   = F10, 15, 0.025   3.0602

Fn1-1, n2-1, α/2  =  1/ F15, 10, 0.025 = 1 / 3.5217 = 0.2839

(Click to zoom in on the table) Now we can plug all of the numbers into the confidence interval formula:

(s12  / s22) * Fn1-1, n2-1,α/2   ≤  σ21 / σ22  ≤  (s12  / s22) * Fn2-1, n1-1, α/2

(28.2 / 19.3) * (0.2839) ≤  σ21 / σ22  ≤  (28.2 / 19.3) * (3.0602)

0.4148 ≤  σ21 / σ22  ≤  4.4714

Thus, the 95% confidence interval for the ratio of the population variances is (0.4148, 4.4714).

## Creating a Confidence Interval Using Excel

The following image shows how to calculate a 95% confidence interval for the ratio of population variances in Excel. The lower and upper bounds of the confidence interval are displayed in column E and the formula used to find the lower and upper bounds are displayed in column F: Thus, the 95% confidence interval for the ratio of the population variances is (0.4148, 4.4714). This matches what we got when we calculated the confidence interval by hand.

## Creating a Confidence Interval Using R

The following code illustrates how to calculate a 95% confidence interval for the ratio of population variances in R:

```#define significance level, sample sizes, and sample variances
alpha <- .05
n1    <- 16
n2    <- 11
var1  <- 28.2
var2  <- 19.3

#define F critical values
upper_crit <- 1/qf(alpha/2, n1-1, n2-1)
lower_crit <- qf(alpha/2, n2-1, n1-1)

#find confidence interval
lower_bound <- (var1/var2) * lower_crit
upper_bound <- (var1/var2) * upper_crit

#output confidence interval
paste0("(", lower_bound, ", ", upper_bound, " )")

# "(0.414899337980266, 4.47137571035219 )"
```

Thus, the 95% confidence interval for the ratio of the population variances is (0.4148, 4.4714). This matches what we got when we calculated the confidence interval by hand.