Chapter 11 - Variance Ratio Test

11.1 Equal Variance Testing - Two Groups

Trout.250 <- c(508, 479, 545, 531, 559, 422, 547, 525, 420, 491, 508, 511, 569, 453, 
    533, 460, 523, 540, 463, 502)
Trout.300 <- c(461, 464, 344, 559, 445, 617, 402, 531, 535, 413, 456, 479, 393, 504, 
    416, 468, 368, 519, 523, 531)
Farmed.Trout <- data.frame(cbind(Trout.250, Trout.300))  # combine as data frame
str(Farmed.Trout)  # wide data - weights of 2 groups in separate columns
## 'data.frame':    20 obs. of  2 variables:
##  $ Trout.250: num  508 479 545 531 559 422 547 525 420 491 ...
##  $ Trout.300: num  461 464 344 559 445 617 402 531 535 413 ...
#> 'data.frame':    20 obs. of  2 variables:
#>  $ Trout.250: num  508 479 545 531 559 422 547 525 420 491 ...
#>  $ Trout.300: num  461 464 344 559 445 617 402 531 535 413 ...
summary(Farmed.Trout)  # compare values of 2 groups
##    Trout.250       Trout.300    
##  Min.   :420.0   Min.   :344.0  
##  1st Qu.:475.0   1st Qu.:415.2  
##  Median :509.5   Median :466.0  
##  Mean   :504.4   Mean   :471.4  
##  3rd Qu.:534.8   3rd Qu.:525.0  
##  Max.   :569.0   Max.   :617.0
#>    Trout.250     Trout.300  
#>  Min.   :420   Min.   :344  
#>  1st Qu.:475   1st Qu.:415  
#>  Median :510   Median :466  
#>  Mean   :504   Mean   :471  
#>  3rd Qu.:535   3rd Qu.:525  
#>  Max.   :569   Max.   :617
# wide data format: use , not ~
with(Farmed.Trout,boxplot(Trout.250,Trout.300, 
     col= "pink",   
     main= "Weights of Aquaculture Raised Rainbow Trout",
     xlab= "Pen density (No. fish)", 
     ylab= "Weight (g)", 
     ylim= c(300,650), 
     names= c("250 per pen","300 per pen"), # group names
     las= 1,  
     boxwex =0.6))

Figure 11.2: Box plot of rainbow trout weight distributions from two aquaculture pen densities (250 fish/pen and 300 fish/pen)

with(Farmed.Trout, var.test(Trout.250, Trout.300))
## 
##  F test to compare two variances
## 
## data:  Trout.250 and Trout.300
## F = 0.38583, num df = 19, denom df = 19, p-value = 0.04421
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  0.1527172 0.9747866
## sample estimates:
## ratio of variances 
##          0.3858324
#> 
#>    F test to compare two variances
#> 
#> data:  Trout.250 and Trout.300
#> F = 0.4, num df = 19, denom df = 19, p-value = 0.04
#> alternative hypothesis: true ratio of variances is not equal to 1
#> 95 percent confidence interval:
#>  0.153 0.975
#> sample estimates:
#> ratio of variances 
#>              0.386