Given an univariate sample \(x\), it tests $$H_0 : \sigma_x^2 \left\lbrace =,\geq,\leq \right\rbrace \sigma_0^2 \quad vs\quad H_1 : \sigma_x^2 \left\lbrace \neq,<,>\right\rbrace \sigma_0^2$$.
var1.chisq(x, var0 = 1, alternative = c("two.sided", "less", "greater"))
a length-\(n\) data vector.
hypothesized variance \(\sigma_0^2\).
specifying the alternative hypothesis.
a (list) object of S3
class htest
containing:
a test statistic.
\(p\)-value under \(H_0\).
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Snedecor GW, Cochran WG (1996). Statistical methods, 8 ed., 7. print edition. Iowa State Univ. Press, Ames, Iowa. ISBN 978-0-8138-1561-9.
## CRAN-purpose small example
x = rnorm(10)
var1.chisq(x, alternative="g") ## Ha : var(x) >= 1
#>
#> One-Sample Chi-Square Test for Variance.
#>
#> data: x
#> statistic = 4.6812, p-value = 0.8612
#> alternative hypothesis: true variance is greater than 1.
#>
var1.chisq(x, alternative="l") ## Ha : var(x) <= 1
#>
#> One-Sample Chi-Square Test for Variance.
#>
#> data: x
#> statistic = 4.6812, p-value = 0.1388
#> alternative hypothesis: true variance is less than 1.
#>
var1.chisq(x, alternative="t") ## Ha : var(x) =/=1
#>
#> One-Sample Chi-Square Test for Variance.
#>
#> data: x
#> statistic = 4.6812, p-value = 0.2777
#> alternative hypothesis: true variance is different from 1.
#>
# \donttest{
## empirical Type 1 error
niter = 1000
counter = rep(0,niter) # record p-values
for (i in 1:niter){
x = rnorm(50) # sample x from N(0,1)
counter[i] = ifelse(var1.chisq(x,var0=1)$p.value < 0.05, 1, 0)
}
## print the result
cat(paste("\n* Example for 'var1.chisq'\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 'var1.chisq'
#> *
#> * number of rejections : 44
#> * total number of trials : 1000
#> * empirical Type 1 error : 0.044
# }