Given two univariate samples \(x\) and \(y\), it tests $$H_0 : \sigma_x^2 \left\lbrace =,\geq,\leq \right\rbrace \sigma_y^2\quad vs\quad H_1 : \sigma_x^2 \left\lbrace \neq,<,>\right\rbrace \sigma_y^2$$.

var2.F(x, y, alternative = c("two.sided", "less", "greater"))

Arguments

x

a length-\(n\) data vector.

y

a length-\(m\) data vector.

alternative

specifying the alternative hypothesis.

Value

a (list) object of S3 class htest containing:

statistic

a test statistic.

p.value

\(p\)-value under \(H_0\).

alternative

alternative hypothesis.

method

name of the test.

data.name

name(s) of provided sample data.

References

Snedecor GW, Cochran WG (1996). Statistical methods, 8 ed., 7. print edition. Iowa State Univ. Press, Ames, Iowa. ISBN 978-0-8138-1561-9.

Examples

## CRAN-purpose small example
x = rnorm(10)
y = rnorm(10)
var2.F(x, y, alternative="g") ## Ha : var(x) >= var(y)
#> 
#> 	Two-Sample F Test for Variance.
#> 
#> data:  x and y
#> statistic = 1.5631, p-value = 0.2581
#> alternative hypothesis: true variance of x is greater than true variance of y.
#> 
var2.F(x, y, alternative="l") ## Ha : var(x) <= var(y)
#> 
#> 	Two-Sample F Test for Variance.
#> 
#> data:  x and y
#> statistic = 1.5631, p-value = 0.7419
#> alternative hypothesis: true variance of x is smaller than true variance of y.
#> 
var2.F(x, y, alternative="t") ## Ha : var(x) =/= var(y)
#> 
#> 	Two-Sample F Test for Variance.
#> 
#> data:  x and y
#> statistic = 1.5631, p-value = 0.5163
#> alternative hypothesis: two true variances are different.
#> 

# \donttest{
## empirical Type 1 error 
niter   = 1000
counter = rep(0,niter)  # record p-values
for (i in 1:niter){
  x = rnorm(57)  # sample x from N(0,1)
  y = rnorm(89)  # sample y from N(0,1)
  
  counter[i] = ifelse(var2.F(x,y)$p.value < 0.05, 1, 0)
}

## print the result
cat(paste("\n* Example for 'var2.F'\n","*\n",
"* number of rejections   : ", sum(counter),"\n",
"* total number of trials : ", niter,"\n",
"* empirical Type 1 error : ",round(sum(counter/niter),5),"\n",sep=""))
#> 
#> * Example for 'var2.F'
#> *
#> * number of rejections   : 48
#> * total number of trials : 1000
#> * empirical Type 1 error : 0.048
# }