R/mvar2.2012ZXC.R
mvar2.2012ZXC.Rd
Given two univariate samples \(x\) and \(y\), it tests $$H_0 : \mu_x = \mu_y, \sigma_x^2 = \sigma_y^2 \quad vs \quad H_1 : \textrm{ not } H_0$$ using exact null distribution for likelihood ratio statistic.
mvar2.2012ZXC(x, y)
a length-\(n\) data vector.
a length-\(m\) data vector.
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.
Zhang L, Xu X, Chen G (2012). “The Exact Likelihood Ratio Test for Equality of Two Normal Populations.” The American Statistician, 66(3), 180--184. ISSN 0003-1305, 1537-2731.
## CRAN-purpose small example
x = rnorm(10)
y = rnorm(10)
mvar2.2012ZXC(x, y)
#>
#> Two-sample Simultaneous Test of Mean and Variance by Zhang, Xu, and
#> Chen (2012).
#>
#> data: x and y
#> statistic = 0.38677, p-value = 0.4408
#> alternative hypothesis: true mean and variance of x are different from those of y.
#>
if (FALSE) {
## empirical Type 1 error
niter = 1000
counter = rep(0,niter) # record p-values
for (i in 1:niter){
x = rnorm(100) # sample x from N(0,1)
y = rnorm(100) # sample y from N(0,1)
counter[i] = ifelse(mvar2.2012ZXC(x,y)$p.value < 0.05, 1, 0)
print(paste("* mvar2.2012ZXC : iteration ",i,"/",niter," complete.",sep=""))
}
## print the result
cat(paste("\n* Example for 'mvar2.2012ZXC'\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=""))
}