Title: | Statistical Hypothesis Testing Toolbox |
---|---|
Description: | We provide a collection of statistical hypothesis testing procedures ranging from classical to modern methods for non-trivial settings such as high-dimensional scenario. For the general treatment of statistical hypothesis testing, see the book by Lehmann and Romano (2005) <doi:10.1007/0-387-27605-X>. |
Authors: | Kyoungjae Lee [aut], Lizhen Lin [aut], Kisung You [aut, cre] |
Maintainer: | Kisung You <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.8 |
Built: | 2024-10-31 06:57:30 UTC |
Source: | CRAN |
Given a multivariate sample and hypothesized covariance matrix
, it tests
using the procedure by Fisher (2012). This method utilizes the generalized form of the inequality
and offers two types of
test statistics and
corresponding to the case
and
respectively.
cov1.2012Fisher(X, Sigma0 = diag(ncol(X)), type)
cov1.2012Fisher(X, Sigma0 = diag(ncol(X)), type)
X |
an |
Sigma0 |
a |
type |
|
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Fisher TJ (2012). “On testing for an identity covariance matrix when the dimensionality equals or exceeds the sample size.” Journal of Statistical Planning and Inference, 142(1), 312–326. ISSN 03783758.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) cov1.2012Fisher(smallX) # run the test ## empirical Type 1 error niter = 1000 counter1 = rep(0,niter) # p-values of the type 1 counter2 = rep(0,niter) # p-values of the type 2 for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=50) # (n,p) = (5,50) counter1[i] = ifelse(cov1.2012Fisher(X, type=1)$p.value < 0.05, 1, 0) counter2[i] = ifelse(cov1.2012Fisher(X, type=2)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'cov1.2012Fisher' \n","*\n", "* empirical error with statistic 1 : ", round(sum(counter1/niter),5),"\n", "* empirical error with statistic 2 : ", round(sum(counter2/niter),5),"\n",sep=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) cov1.2012Fisher(smallX) # run the test ## empirical Type 1 error niter = 1000 counter1 = rep(0,niter) # p-values of the type 1 counter2 = rep(0,niter) # p-values of the type 2 for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=50) # (n,p) = (5,50) counter1[i] = ifelse(cov1.2012Fisher(X, type=1)$p.value < 0.05, 1, 0) counter2[i] = ifelse(cov1.2012Fisher(X, type=2)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'cov1.2012Fisher' \n","*\n", "* empirical error with statistic 1 : ", round(sum(counter1/niter),5),"\n", "* empirical error with statistic 2 : ", round(sum(counter2/niter),5),"\n",sep=""))
Given a multivariate sample and hypothesized covariance matrix
, it tests
using the procedure by Wu and Li (2015). They proposed to use number of multiple random projections
since only a single operation might attenuate the efficacy of the test.
cov1.2015WL(X, Sigma0 = diag(ncol(X)), m = 25)
cov1.2015WL(X, Sigma0 = diag(ncol(X)), m = 25)
X |
an |
Sigma0 |
a |
m |
the number of random projections to be applied. |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Wu T, Li P (2015). “Tests for High-Dimensional Covariance Matrices Using Random Matrix Projection.” arXiv:1511.01611 [stat].
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) cov1.2015WL(smallX) # run the test ## empirical Type 1 error ## compare effects of m=5, 10, 50 niter = 1000 rec1 = rep(0,niter) # for m=5 rec2 = rep(0,niter) # m=10 rec3 = rep(0,niter) # m=50 for (i in 1:niter){ X = matrix(rnorm(50*10), ncol=50) # (n,p) = (10,50) rec1[i] = ifelse(cov1.2015WL(X, m=5)$p.value < 0.05, 1, 0) rec2[i] = ifelse(cov1.2015WL(X, m=10)$p.value < 0.05, 1, 0) rec3[i] = ifelse(cov1.2015WL(X, m=50)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'cov1.2015WL'\n","*\n", "* Type 1 error with m=5 : ",round(sum(rec1/niter),5),"\n", "* Type 1 error with m=10 : ",round(sum(rec2/niter),5),"\n", "* Type 1 error with m=50 : ",round(sum(rec3/niter),5),"\n",sep=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) cov1.2015WL(smallX) # run the test ## empirical Type 1 error ## compare effects of m=5, 10, 50 niter = 1000 rec1 = rep(0,niter) # for m=5 rec2 = rep(0,niter) # m=10 rec3 = rep(0,niter) # m=50 for (i in 1:niter){ X = matrix(rnorm(50*10), ncol=50) # (n,p) = (10,50) rec1[i] = ifelse(cov1.2015WL(X, m=5)$p.value < 0.05, 1, 0) rec2[i] = ifelse(cov1.2015WL(X, m=10)$p.value < 0.05, 1, 0) rec3[i] = ifelse(cov1.2015WL(X, m=50)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'cov1.2015WL'\n","*\n", "* Type 1 error with m=5 : ",round(sum(rec1/niter),5),"\n", "* Type 1 error with m=10 : ",round(sum(rec2/niter),5),"\n", "* Type 1 error with m=50 : ",round(sum(rec3/niter),5),"\n",sep=""))
Given two multivariate data and
of same dimension, it tests
using the procedure by Li and Chen (2012).
cov2.2012LC(X, Y, use.unbiased = TRUE)
cov2.2012LC(X, Y, use.unbiased = TRUE)
X |
an |
Y |
an |
use.unbiased |
a logical; |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Li J, Chen SX (2012). “Two sample tests for high-dimensional covariance matrices.” The Annals of Statistics, 40(2), 908–940. ISSN 0090-5364.
## CRAN-purpose small example smallX = matrix(rnorm(10*4),ncol=5) smallY = matrix(rnorm(10*4),ncol=5) cov2.2012LC(smallX, smallY) # run the test ## Not run: ## empirical Type 1 error : use 'biased' version for faster computation niter = 1000 counter = rep(0,niter) for (i in 1:niter){ X = matrix(rnorm(500*25), ncol=10) Y = matrix(rnorm(500*25), ncol=10) counter[i] = ifelse(cov2.2012LC(X,Y,use.unbiased=FALSE)$p.value < 0.05,1,0) print(paste0("iteration ",i,"/1000 complete..")) } ## print the result cat(paste("\n* Example for 'cov2.2012LC'\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="")) ## End(Not run)
## CRAN-purpose small example smallX = matrix(rnorm(10*4),ncol=5) smallY = matrix(rnorm(10*4),ncol=5) cov2.2012LC(smallX, smallY) # run the test ## Not run: ## empirical Type 1 error : use 'biased' version for faster computation niter = 1000 counter = rep(0,niter) for (i in 1:niter){ X = matrix(rnorm(500*25), ncol=10) Y = matrix(rnorm(500*25), ncol=10) counter[i] = ifelse(cov2.2012LC(X,Y,use.unbiased=FALSE)$p.value < 0.05,1,0) print(paste0("iteration ",i,"/1000 complete..")) } ## print the result cat(paste("\n* Example for 'cov2.2012LC'\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="")) ## End(Not run)
Given two multivariate data and
of same dimension, it tests
using the procedure by Cai, Liu, and Xia (2013).
cov2.2013CLX(X, Y)
cov2.2013CLX(X, Y)
X |
an |
Y |
an |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Cai T, Liu W, Xia Y (2013). “Two-Sample Covariance Matrix Testing and Support Recovery in High-Dimensional and Sparse Settings.” Journal of the American Statistical Association, 108(501), 265–277. ISSN 0162-1459, 1537-274X.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) cov2.2013CLX(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(cov2.2013CLX(X, Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'cov2.2013CLX'\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=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) cov2.2013CLX(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(cov2.2013CLX(X, Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'cov2.2013CLX'\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=""))
Given two multivariate data and
of same dimension, it tests
using the procedure by Wu and Li (2015).
cov2.2015WL(X, Y, m = 50)
cov2.2015WL(X, Y, m = 50)
X |
an |
Y |
an |
m |
the number of random projections to be applied. |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Wu T, Li P (2015). “Tests for High-Dimensional Covariance Matrices Using Random Matrix Projection.” arXiv:1511.01611 [stat].
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) cov2.2015WL(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(cov2.2015WL(X, Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'cov2.2015WL'\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=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) cov2.2015WL(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(cov2.2015WL(X, Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'cov2.2015WL'\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=""))
Given univariate samples , it tests
using the procedure by Schott (2001) using Wald statistics. In the original paper, it provides 4 different test statistics for general elliptical distribution cases. However, we only deliver the first one with an assumption of multivariate normal population.
covk.2001Schott(dlist)
covk.2001Schott(dlist)
dlist |
a list of length |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Schott JR (2001). “Some tests for the equality of covariance matrices.” Journal of Statistical Planning and Inference, 94(1), 25–36. ISSN 03783758.
## CRAN-purpose small example tinylist = list() for (i in 1:3){ # consider 3-sample case tinylist[[i]] = matrix(rnorm(10*3),ncol=3) } covk.2001Schott(tinylist) # run the test ## Not run: ## test when k=5 samples with (n,p) = (100,20) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = matrix(rnorm(100*20),ncol=20) } counter[i] = ifelse(covk.2001Schott(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'covk.2001Schott'\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="")) ## End(Not run)
## CRAN-purpose small example tinylist = list() for (i in 1:3){ # consider 3-sample case tinylist[[i]] = matrix(rnorm(10*3),ncol=3) } covk.2001Schott(tinylist) # run the test ## Not run: ## test when k=5 samples with (n,p) = (100,20) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = matrix(rnorm(100*20),ncol=20) } counter[i] = ifelse(covk.2001Schott(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'covk.2001Schott'\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="")) ## End(Not run)
Given univariate samples , it tests
using the procedure by Schott (2007).
covk.2007Schott(dlist)
covk.2007Schott(dlist)
dlist |
a list of length |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Schott JR (2007). “A test for the equality of covariance matrices when the dimension is large relative to the sample sizes.” Computational Statistics & Data Analysis, 51(12), 6535–6542. ISSN 01679473.
## CRAN-purpose small example tinylist = list() for (i in 1:3){ # consider 3-sample case tinylist[[i]] = matrix(rnorm(10*3),ncol=3) } covk.2007Schott(tinylist) # run the test ## test when k=4 samples with (n,p) = (100,20) ## empirical Type 1 error niter = 1234 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:4){ mylist[[j]] = matrix(rnorm(100*20),ncol=20) } counter[i] = ifelse(covk.2007Schott(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'covk.2007Schott'\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=""))
## CRAN-purpose small example tinylist = list() for (i in 1:3){ # consider 3-sample case tinylist[[i]] = matrix(rnorm(10*3),ncol=3) } covk.2007Schott(tinylist) # run the test ## test when k=4 samples with (n,p) = (100,20) ## empirical Type 1 error niter = 1234 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:4){ mylist[[j]] = matrix(rnorm(100*20),ncol=20) } counter[i] = ifelse(covk.2007Schott(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'covk.2007Schott'\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=""))
Given two samples (either univariate or multivariate) and
of same dimension, it tests
using the procedure by Biswas and Ghosh (2014) in a nonparametric way based on
pairwise distance measures. Both asymptotic and permutation-based determination of
-values are supported.
eqdist.2014BG(X, Y, method = c("permutation", "asymptotic"), nreps = 999)
eqdist.2014BG(X, Y, method = c("permutation", "asymptotic"), nreps = 999)
X |
a vector/matrix of 1st sample. |
Y |
a vector/matrix of 2nd sample. |
method |
method to compute |
nreps |
the number of permutations to be run when |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Biswas M, Ghosh AK (2014). “A nonparametric two-sample test applicable to high dimensional data.” Journal of Multivariate Analysis, 123, 160–171. ISSN 0047259X.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) eqdist.2014BG(smallX, smallY) # run the test ## Not run: ## compare asymptotic and permutation-based powers set.seed(777) ntest = 1000 pval.a = rep(0,ntest) pval.p = rep(0,ntest) for (i in 1:ntest){ x = matrix(rnorm(100), nrow=5) y = matrix(rnorm(100), nrow=5) pval.a[i] = ifelse(eqdist.2014BG(x,y,method="a")$p.value<0.05,1,0) pval.p[i] = ifelse(eqdist.2014BG(x,y,method="p",nreps=100)$p.value <0.05,1,0) } ## print the result cat(paste("\n* EMPIRICAL TYPE 1 ERROR COMPARISON \n","*\n", "* Asymptotics : ", round(sum(pval.a/ntest),5),"\n", "* Permutation : ", round(sum(pval.p/ntest),5),"\n",sep="")) ## End(Not run)
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) eqdist.2014BG(smallX, smallY) # run the test ## Not run: ## compare asymptotic and permutation-based powers set.seed(777) ntest = 1000 pval.a = rep(0,ntest) pval.p = rep(0,ntest) for (i in 1:ntest){ x = matrix(rnorm(100), nrow=5) y = matrix(rnorm(100), nrow=5) pval.a[i] = ifelse(eqdist.2014BG(x,y,method="a")$p.value<0.05,1,0) pval.p[i] = ifelse(eqdist.2014BG(x,y,method="p",nreps=100)$p.value <0.05,1,0) } ## print the result cat(paste("\n* EMPIRICAL TYPE 1 ERROR COMPARISON \n","*\n", "* Asymptotics : ", round(sum(pval.a/ntest),5),"\n", "* Permutation : ", round(sum(pval.p/ntest),5),"\n",sep="")) ## End(Not run)
Given a multivariate sample and hypothesized mean
, it tests
using the procedure by Hotelling (1931).
mean1.1931Hotelling(X, mu0 = rep(0, ncol(X)))
mean1.1931Hotelling(X, mu0 = rep(0, ncol(X)))
X |
an |
mu0 |
a length- |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Hotelling H (1931). “The Generalization of Student's Ratio.” The Annals of Mathematical Statistics, 2(3), 360–378. ISSN 0003-4851.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) mean1.1931Hotelling(smallX) # run the test ## Not run: ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=5) counter[i] = ifelse(mean1.1931Hotelling(X)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean1.1931Hotelling'\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="")) ## End(Not run)
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) mean1.1931Hotelling(smallX) # run the test ## Not run: ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=5) counter[i] = ifelse(mean1.1931Hotelling(X)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean1.1931Hotelling'\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="")) ## End(Not run)
Given a multivariate sample and hypothesized mean
, it tests
using the procedure by Dempster (1958, 1960).
mean1.1958Dempster(X, mu0 = rep(0, ncol(X)))
mean1.1958Dempster(X, mu0 = rep(0, ncol(X)))
X |
an |
mu0 |
a length- |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Dempster AP (1958). “A High Dimensional Two Sample Significance Test.” The Annals of Mathematical Statistics, 29(4), 995–1010. ISSN 0003-4851.
Dempster AP (1960). “A Significance Test for the Separation of Two Highly Multivariate Small Samples.” Biometrics, 16(1), 41. ISSN 0006341X.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) mean1.1958Dempster(smallX) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=50) counter[i] = ifelse(mean1.1958Dempster(X)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean1.1958Dempster'\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=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) mean1.1958Dempster(smallX) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=50) counter[i] = ifelse(mean1.1958Dempster(X)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean1.1958Dempster'\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=""))
Given a multivariate sample and hypothesized mean
, it tests
using the procedure by Bai and Saranadasa (1996).
mean1.1996BS(X, mu0 = rep(0, ncol(X)))
mean1.1996BS(X, mu0 = rep(0, ncol(X)))
X |
an |
mu0 |
a length- |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Bai Z, Saranadasa H (1996). “HIGH DIMENSION: BY AN EXAMPLE OF A TWO SAMPLE PROBLEM.” Statistica Sinica, 6(2), 311–329. ISSN 10170405, 19968507.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) mean1.1996BS(smallX) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=25) counter[i] = ifelse(mean1.1996BS(X)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean1.1996BS'\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=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) mean1.1996BS(smallX) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=25) counter[i] = ifelse(mean1.1996BS(X)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean1.1996BS'\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=""))
Given a multivariate sample and hypothesized mean
, it tests
using the procedure by Srivastava and Du (2008).
mean1.2008SD(X, mu0 = rep(0, ncol(X)))
mean1.2008SD(X, mu0 = rep(0, ncol(X)))
X |
an |
mu0 |
a length- |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Srivastava MS, Du M (2008). “A test for the mean vector with fewer observations than the dimension.” Journal of Multivariate Analysis, 99(3), 386–402. ISSN 0047259X.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) mean1.2008SD(smallX) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=5) counter[i] = ifelse(mean1.2008SD(X)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean1.2008SD'\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=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) mean1.2008SD(smallX) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=5) counter[i] = ifelse(mean1.2008SD(X)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean1.2008SD'\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=""))
Given an univariate sample , it tests
using the procedure by Student (1908).
mean1.ttest(x, mu0 = 0, alternative = c("two.sided", "less", "greater"))
mean1.ttest(x, mu0 = 0, alternative = c("two.sided", "less", "greater"))
x |
a length- |
mu0 |
hypothesized mean |
alternative |
specifying the alternative hypothesis. |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Student (1908). “The Probable Error of a Mean.” Biometrika, 6(1), 1. ISSN 00063444.
Student (1908). “Probable Error of a Correlation Coefficient.” Biometrika, 6(2-3), 302–310. ISSN 0006-3444, 1464-3510.
## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ x = rnorm(10) # sample from N(0,1) counter[i] = ifelse(mean1.ttest(x)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean1.ttest'\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=""))
## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ x = rnorm(10) # sample from N(0,1) counter[i] = ifelse(mean1.ttest(x)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean1.ttest'\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=""))
Given two multivariate data and
of same dimension, it tests
using the procedure by Hotelling (1931).
mean2.1931Hotelling(X, Y, paired = FALSE, var.equal = TRUE)
mean2.1931Hotelling(X, Y, paired = FALSE, var.equal = TRUE)
X |
an |
Y |
an |
paired |
a logical; whether you want a paired Hotelling's test. |
var.equal |
a logical; whether to treat the two covariances as being equal. |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Hotelling H (1931). “The Generalization of Student's Ratio.” The Annals of Mathematical Statistics, 2(3), 360–378. ISSN 0003-4851.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.1931Hotelling(smallX, smallY) # run the test ## generate two samples from standard normal distributions. X = matrix(rnorm(50*5), ncol=5) Y = matrix(rnorm(77*5), ncol=5) ## run single test print(mean2.1931Hotelling(X,Y)) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=5) Y = matrix(rnorm(77*5), ncol=5) counter[i] = ifelse(mean2.1931Hotelling(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.1931Hotelling'\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=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.1931Hotelling(smallX, smallY) # run the test ## generate two samples from standard normal distributions. X = matrix(rnorm(50*5), ncol=5) Y = matrix(rnorm(77*5), ncol=5) ## run single test print(mean2.1931Hotelling(X,Y)) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=5) Y = matrix(rnorm(77*5), ncol=5) counter[i] = ifelse(mean2.1931Hotelling(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.1931Hotelling'\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=""))
Given two multivariate data and
of same dimension, it tests
using the procedure by Dempster (1958, 1960).
mean2.1958Dempster(X, Y)
mean2.1958Dempster(X, Y)
X |
an |
Y |
an |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Dempster AP (1958). “A High Dimensional Two Sample Significance Test.” The Annals of Mathematical Statistics, 29(4), 995–1010. ISSN 0003-4851.
Dempster AP (1960). “A Significance Test for the Separation of Two Highly Multivariate Small Samples.” Biometrics, 16(1), 41. ISSN 0006341X.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.1958Dempster(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.1958Dempster(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.1958Dempster'\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=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.1958Dempster(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.1958Dempster(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.1958Dempster'\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=""))
Given two multivariate data and
of same dimension, it tests
using the procedure by Yao (1965) via multivariate modification of Welch's approximation of degrees of freedoms.
mean2.1965Yao(X, Y)
mean2.1965Yao(X, Y)
X |
an |
Y |
an |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Yao Y (1965). “An Approximate Degrees of Freedom Solution to the Multivariate Behrens Fisher Problem.” Biometrika, 52(1/2), 139. ISSN 00063444.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.1965Yao(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.1965Yao(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.1965Yao'\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=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.1965Yao(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.1965Yao(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.1965Yao'\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=""))
Given two multivariate data and
of same dimension, it tests
using the procedure by Johansen (1980) by adapting Welch-James approximation
of the degree of freedom for Hotelling's test.
mean2.1980Johansen(X, Y)
mean2.1980Johansen(X, Y)
X |
an |
Y |
an |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Johansen S (1980). “The Welch-James Approximation to the Distribution of the Residual Sum of Squares in a Weighted Linear Regression.” Biometrika, 67(1), 85. ISSN 00063444.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.1980Johansen(smallX, smallY) # run the test ## Not run: ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.1980Johansen(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.1980Johansen'\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="")) ## End(Not run)
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.1980Johansen(smallX, smallY) # run the test ## Not run: ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.1980Johansen(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.1980Johansen'\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="")) ## End(Not run)
Given two multivariate data and
of same dimension, it tests
using the procedure by Nel and Van der Merwe (1986).
mean2.1986NVM(X, Y)
mean2.1986NVM(X, Y)
X |
an |
Y |
an |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Nel DG, Van Der Merwe CA (1986). “A solution to the multivariate behrens-fisher problem.” Communications in Statistics - Theory and Methods, 15(12), 3719–3735. ISSN 0361-0926, 1532-415X.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.1986NVM(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.1986NVM(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.1986NVM'\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=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.1986NVM(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.1986NVM(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.1986NVM'\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=""))
Given two multivariate data and
of same dimension, it tests
using the procedure by Bai and Saranadasa (1996).
mean2.1996BS(X, Y)
mean2.1996BS(X, Y)
X |
an |
Y |
an |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Bai Z, Saranadasa H (1996). “HIGH DIMENSION: BY AN EXAMPLE OF A TWO SAMPLE PROBLEM.” Statistica Sinica, 6(2), 311–329. ISSN 10170405, 19968507.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.1996BS(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.1996BS(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.1996BS'\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=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.1996BS(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.1996BS(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.1996BS'\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=""))
Given two multivariate data and
of same dimension, it tests
using the procedure by Krishnamoorthy and Yu (2004), which is a modified version of Nel and Van der Merwe (1986).
mean2.2004KY(X, Y)
mean2.2004KY(X, Y)
X |
an |
Y |
an |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Krishnamoorthy K, Yu J (2004). “Modified Nel and Van der Merwe test for the multivariate Behrens–Fisher problem.” Statistics & Probability Letters, 66(2), 161–169. ISSN 01677152.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.2004KY(smallX, smallY) # run the test ## Not run: ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.2004KY(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.2004KY'\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="")) ## End(Not run)
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.2004KY(smallX, smallY) # run the test ## Not run: ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.2004KY(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.2004KY'\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="")) ## End(Not run)
Given two multivariate data and
of same dimension, it tests
using the procedure by Srivastava and Du (2008).
mean2.2008SD(X, Y)
mean2.2008SD(X, Y)
X |
an |
Y |
an |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Srivastava MS, Du M (2008). “A test for the mean vector with fewer observations than the dimension.” Journal of Multivariate Analysis, 99(3), 386–402. ISSN 0047259X.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.2008SD(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.2008SD(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.2008SD'\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=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.2008SD(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.2008SD(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.2008SD'\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=""))
Given two multivariate data and
of same dimension, it tests
using the procedure by Lopes, Jacob, and Wainwright (2011) using random projection.
Due to solving system of linear equations, we suggest you to opt for asymptotic-based
-value computation unless truly necessary for random permutation tests.
mean2.2011LJW(X, Y, method = c("asymptotic", "MC"), nreps = 1000)
mean2.2011LJW(X, Y, method = c("asymptotic", "MC"), nreps = 1000)
X |
an |
Y |
an |
method |
method to compute |
nreps |
the number of permutation iterations to be run when |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Lopes ME, Jacob L, Wainwright MJ (2011). “A More Powerful Two-sample Test in High Dimensions Using Random Projection.” In Proceedings of the 24th International Conference on Neural Information Processing Systems, NIPS'11, 1206–1214. ISBN 978-1-61839-599-3.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=10) smallY = matrix(rnorm(10*3),ncol=10) mean2.2011LJW(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(10*20), ncol=20) Y = matrix(rnorm(10*20), ncol=20) counter[i] = ifelse(mean2.2011LJW(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.2011LJW'\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=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=10) smallY = matrix(rnorm(10*3),ncol=10) mean2.2011LJW(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(10*20), ncol=20) Y = matrix(rnorm(10*20), ncol=20) counter[i] = ifelse(mean2.2011LJW(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.2011LJW'\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=""))
Given two multivariate data and
of same dimension, it tests
using the procedure by Cai, Liu, and Xia (2014) which is equivalent to test
for an inverse covariance (or precision) . When
is not given
and known to be sparse, it is first estimated with CLIME estimator. Otherwise,
adaptive thresholding estimator is used. Also, if two samples
are assumed to have different covariance structure, it uses weighting scheme for adjustment.
mean2.2014CLX( X, Y, precision = c("sparse", "unknown"), delta = 2, Omega = NULL, cov.equal = TRUE )
mean2.2014CLX( X, Y, precision = c("sparse", "unknown"), delta = 2, Omega = NULL, cov.equal = TRUE )
X |
an |
Y |
an |
precision |
type of assumption for a precision matrix (default: |
delta |
an algorithmic parameter for adaptive thresholding estimation (default: 2). |
Omega |
precision matrix; if |
cov.equal |
a logical to determine homogeneous covariance assumption. |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Cai TT, Liu W, Xia Y (2014). “Two-sample test of high dimensional means under dependence.” Journal of the Royal Statistical Society: Series B (Statistical Methodology), 76(2), 349–372. ISSN 13697412.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.2014CLX(smallX, smallY, precision="unknown") mean2.2014CLX(smallX, smallY, precision="sparse") ## Not run: ## empirical Type 1 error niter = 100 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.2014CLX(X, Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.2014CLX'\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="")) ## End(Not run)
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) mean2.2014CLX(smallX, smallY, precision="unknown") mean2.2014CLX(smallX, smallY, precision="sparse") ## Not run: ## empirical Type 1 error niter = 100 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(mean2.2014CLX(X, Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.2014CLX'\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="")) ## End(Not run)
Given two multivariate data and
of same dimension, it tests
using the procedure by Thulin (2014) using random subspace methods. We did not enable parallel computing schemes for this in that it might incur huge computational burden since it entirely depends on random permutation scheme.
mean2.2014Thulin(X, Y, B = 100, nreps = 1000)
mean2.2014Thulin(X, Y, B = 100, nreps = 1000)
X |
an |
Y |
an |
B |
the number of selected subsets for averaging. |
nreps |
the number of permutation iterations to be run. |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Thulin M (2014). “A high-dimensional two-sample test for the mean using random subspaces.” Computational Statistics & Data Analysis, 74, 26–38. ISSN 01679473.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=10) smallY = matrix(rnorm(10*3),ncol=10) mean2.2014Thulin(smallX, smallY, B=10, nreps=10) # run the test ## Compare with 'mean2.2011LJW' ## which is based on random projection. n = 33 # number of observations for each sample p = 100 # dimensionality X = matrix(rnorm(n*p), ncol=p) Y = matrix(rnorm(n*p), ncol=p) ## run both methods with 100 permutations mean2.2011LJW(X,Y,nreps=100,method="m") # 2011LJW requires 'm' to be set. mean2.2014Thulin(X,Y,nreps=100)
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=10) smallY = matrix(rnorm(10*3),ncol=10) mean2.2014Thulin(smallX, smallY, B=10, nreps=10) # run the test ## Compare with 'mean2.2011LJW' ## which is based on random projection. n = 33 # number of observations for each sample p = 100 # dimensionality X = matrix(rnorm(n*p), ncol=p) Y = matrix(rnorm(n*p), ncol=p) ## run both methods with 100 permutations mean2.2011LJW(X,Y,nreps=100,method="m") # 2011LJW requires 'm' to be set. mean2.2014Thulin(X,Y,nreps=100)
Not Written Here - No Reference Yet.
mean2.mxPBF(X, Y, a0 = 0, b0 = 0, gamma = 1, nthreads = 1)
mean2.mxPBF(X, Y, a0 = 0, b0 = 0, gamma = 1, nthreads = 1)
X |
an |
Y |
an |
a0 |
shape parameter for inverse-gamma prior (default: 0). |
b0 |
scale parameter for inverse-gamma prior (default: 0). |
gamma |
non-negative variance scaling parameter (default: 1). |
nthreads |
number of threads for parallel execution via OpenMP (default: 1). |
a (list) object of S3
class htest
containing:
maximum of pairwise Bayes factor.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
vector of pairwise Bayes factors in natural log.
## Not run: ## empirical Type 1 error with BF threshold = 10 niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(100*10), ncol=10) Y = matrix(rnorm(200*10), ncol=10) counter[i] = ifelse(mean2.mxPBF(X,Y)$statistic > 10, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.mxPBF'\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="")) ## End(Not run)
## Not run: ## empirical Type 1 error with BF threshold = 10 niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(100*10), ncol=10) Y = matrix(rnorm(200*10), ncol=10) counter[i] = ifelse(mean2.mxPBF(X,Y)$statistic > 10, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.mxPBF'\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="")) ## End(Not run)
Given two univariate samples and
, it tests
using the procedure by Student (1908) and Welch (1947).
mean2.ttest( x, y, alternative = c("two.sided", "less", "greater"), paired = FALSE, var.equal = FALSE )
mean2.ttest( x, y, alternative = c("two.sided", "less", "greater"), paired = FALSE, var.equal = FALSE )
x |
a length- |
y |
a length- |
alternative |
specifying the alternative hypothesis. |
paired |
a logical; whether consider two samples as paired. |
var.equal |
a logical; if |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Student (1908). “The Probable Error of a Mean.” Biometrika, 6(1), 1. ISSN 00063444.
Student (1908). “Probable Error of a Correlation Coefficient.” Biometrika, 6(2-3), 302–310. ISSN 0006-3444, 1464-3510.
Welch BL (1947). “The Generalization of ‘Student’s' Problem when Several Different Population Variances are Involved.” Biometrika, 34(1/2), 28. ISSN 00063444.
## 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(mean2.ttest(x,y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.ttest'\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=""))
## 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(mean2.ttest(x,y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mean2.ttest'\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=""))
Given univariate samples , it tests
using the procedure by Schott (2007). It can be considered as a generalization
of two-sample testing procedure proposed by Bai and Saranadasa (1996)
.
meank.2007Schott(dlist)
meank.2007Schott(dlist)
dlist |
a list of length |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Schott JR (2007). “Some high-dimensional tests for a one-way MANOVA.” Journal of Multivariate Analysis, 98(9), 1825–1839. ISSN 0047259X.
## CRAN-purpose small example tinylist = list() for (i in 1:3){ # consider 3-sample case tinylist[[i]] = matrix(rnorm(10*3),ncol=3) } meank.2007Schott(tinylist) ## test when k=5 samples with (n,p) = (10,50) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = matrix(rnorm(10*5),ncol=5) } counter[i] = ifelse(meank.2007Schott(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'meank.2007Schott'\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=""))
## CRAN-purpose small example tinylist = list() for (i in 1:3){ # consider 3-sample case tinylist[[i]] = matrix(rnorm(10*3),ncol=3) } meank.2007Schott(tinylist) ## test when k=5 samples with (n,p) = (10,50) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = matrix(rnorm(10*5),ncol=5) } counter[i] = ifelse(meank.2007Schott(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'meank.2007Schott'\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=""))
Given univariate samples , it tests
using the procedure by Zhang and Xu (2009) by applying multivariate extension of Scheffe's method of transformation.
meank.2009ZX(dlist, method = c("L", "T"))
meank.2009ZX(dlist, method = c("L", "T"))
dlist |
a list of length |
method |
a method to be applied for the transformed problem. |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Zhang J, Xu J (2009). “On the k-sample Behrens-Fisher problem for high-dimensional data.” Science in China Series A: Mathematics, 52(6), 1285–1304. ISSN 1862-2763.
## CRAN-purpose small example tinylist = list() for (i in 1:3){ # consider 3-sample case tinylist[[i]] = matrix(rnorm(10*3),ncol=3) } meank.2009ZX(tinylist) # run the test ## test when k=5 samples with (n,p) = (100,20) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = matrix(rnorm(100*10),ncol=10) } counter[i] = ifelse(meank.2009ZX(mylist, method="L")$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'meank.2009ZX'\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=""))
## CRAN-purpose small example tinylist = list() for (i in 1:3){ # consider 3-sample case tinylist[[i]] = matrix(rnorm(10*3),ncol=3) } meank.2009ZX(tinylist) # run the test ## test when k=5 samples with (n,p) = (100,20) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = matrix(rnorm(100*10),ncol=10) } counter[i] = ifelse(meank.2009ZX(mylist, method="L")$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'meank.2009ZX'\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=""))
Given univariate samples , it tests
using the procedure by Cao, Park, and He (2019).
meank.2019CPH(dlist, method = c("original", "Hu"))
meank.2019CPH(dlist, method = c("original", "Hu"))
dlist |
a list of length |
method |
a method to be applied to estimate variance parameter. |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Cao M, Park J, He D (2019). “A test for the k sample Behrens–Fisher problem in high dimensional data.” Journal of Statistical Planning and Inference, 201, 86–102. ISSN 03783758.
## CRAN-purpose small example tinylist = list() for (i in 1:3){ # consider 3-sample case tinylist[[i]] = matrix(rnorm(10*3),ncol=3) } meank.2019CPH(tinylist, method="o") # newly-proposed variance estimator meank.2019CPH(tinylist, method="h") # adopt one from 2017Hu ## Not run: ## test when k=5 samples with (n,p) = (10,50) ## empirical Type 1 error niter = 10000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = matrix(rnorm(10*50),ncol=50) } counter[i] = ifelse(meank.2019CPH(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'meank.2019CPH'\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="")) ## End(Not run)
## CRAN-purpose small example tinylist = list() for (i in 1:3){ # consider 3-sample case tinylist[[i]] = matrix(rnorm(10*3),ncol=3) } meank.2019CPH(tinylist, method="o") # newly-proposed variance estimator meank.2019CPH(tinylist, method="h") # adopt one from 2017Hu ## Not run: ## test when k=5 samples with (n,p) = (10,50) ## empirical Type 1 error niter = 10000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = matrix(rnorm(10*50),ncol=50) } counter[i] = ifelse(meank.2019CPH(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'meank.2019CPH'\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="")) ## End(Not run)
Given univariate samples , it tests
meank.anova(dlist)
meank.anova(dlist)
dlist |
a list of length |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
## test when k=5 (samples) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = rnorm(50) } counter[i] = ifelse(meank.anova(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'meank.anova'\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=""))
## test when k=5 (samples) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = rnorm(50) } counter[i] = ifelse(meank.anova(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'meank.anova'\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=""))
Given two univariate samples and
, it tests
using asymptotic likelihood ratio test.
mvar1.1998AS(x, mu0 = 0, var0 = 1)
mvar1.1998AS(x, mu0 = 0, var0 = 1)
x |
a length- |
mu0 |
hypothesized mean |
var0 |
hypothesized variance |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Arnold BC, Shavelle RM (1998). “Joint Confidence Sets for the Mean and Variance of a Normal Distribution.” The American Statistician, 52(2), 133–140.
## CRAN-purpose small example mvar1.1998AS(rnorm(10)) ## Not run: ## 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) counter[i] = ifelse(mvar1.1998AS(x)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mvar1.1998AS'\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="")) ## End(Not run)
## CRAN-purpose small example mvar1.1998AS(rnorm(10)) ## Not run: ## 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) counter[i] = ifelse(mvar1.1998AS(x)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mvar1.1998AS'\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="")) ## End(Not run)
Given two univariate samples and
, it tests
using likelihood ratio test.
mvar1.LRT(x, mu0 = 0, var0 = 1)
mvar1.LRT(x, mu0 = 0, var0 = 1)
x |
a length- |
mu0 |
hypothesized mean |
var0 |
hypothesized variance |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
## CRAN-purpose small example mvar1.LRT(rnorm(10)) ## Not run: ## 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) counter[i] = ifelse(mvar1.LRT(x)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mvar1.LRT'\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="")) ## End(Not run)
## CRAN-purpose small example mvar1.LRT(rnorm(10)) ## Not run: ## 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) counter[i] = ifelse(mvar1.LRT(x)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mvar1.LRT'\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="")) ## End(Not run)
Given two univariate samples and
, it tests
by approximating the null distribution with Beta distribution using the first two moments matching.
mvar2.1930PN(x, y)
mvar2.1930PN(x, y)
x |
a length- |
y |
a length- |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
## CRAN-purpose small example x = rnorm(10) y = rnorm(10) mvar2.1930PN(x, y) ## Not run: ## 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.1930PN(x,y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mvar2.1930PN'\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="")) ## End(Not run)
## CRAN-purpose small example x = rnorm(10) y = rnorm(10) mvar2.1930PN(x, y) ## Not run: ## 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.1930PN(x,y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mvar2.1930PN'\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="")) ## End(Not run)
Given two univariate samples and
, it tests
using Fisher's method of merging two -values.
mvar2.1976PL(x, y)
mvar2.1976PL(x, y)
x |
a length- |
y |
a length- |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Perng SK, Littell RC (1976). “A Test of Equality of Two Normal Population Means and Variances.” Journal of the American Statistical Association, 71(356), 968–971. ISSN 0162-1459, 1537-274X.
## CRAN-purpose small example x = rnorm(10) y = rnorm(10) mvar2.1976PL(x, y) ## Not run: ## 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.1976PL(x,y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mvar2.1976PL'\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="")) ## End(Not run)
## CRAN-purpose small example x = rnorm(10) y = rnorm(10) mvar2.1976PL(x, y) ## Not run: ## 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.1976PL(x,y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mvar2.1976PL'\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="")) ## End(Not run)
Given two univariate samples and
, it tests
using Muirhead's approximation for small-sample problem.
mvar2.1982Muirhead(x, y)
mvar2.1982Muirhead(x, y)
x |
a length- |
y |
a length- |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Muirhead RJ (1982). Aspects of multivariate statistical theory, Wiley series in probability and mathematical statistics. Wiley, New York. ISBN 978-0-471-09442-5.
## CRAN-purpose small example x = rnorm(10) y = rnorm(10) mvar2.1982Muirhead(x, y) ## Not run: ## 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.1982Muirhead(x,y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mvar2.1982Muirhead'\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="")) ## End(Not run)
## CRAN-purpose small example x = rnorm(10) y = rnorm(10) mvar2.1982Muirhead(x, y) ## Not run: ## 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.1982Muirhead(x,y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mvar2.1982Muirhead'\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="")) ## End(Not run)
Given two univariate samples and
, it tests
using exact null distribution for likelihood ratio statistic.
mvar2.2012ZXC(x, y)
mvar2.2012ZXC(x, y)
x |
a length- |
y |
a length- |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
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) ## Not run: ## 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="")) ## End(Not run)
## CRAN-purpose small example x = rnorm(10) y = rnorm(10) mvar2.2012ZXC(x, y) ## Not run: ## 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="")) ## End(Not run)
Given two univariate samples and
, it tests
using classical likelihood ratio test.
mvar2.LRT(x, y)
mvar2.LRT(x, y)
x |
a length- |
y |
a length- |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
## CRAN-purpose small example x = rnorm(10) y = rnorm(10) mvar2.LRT(x, y) ## Not run: ## 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.LRT(x,y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mvar2.LRT'\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="")) ## End(Not run)
## CRAN-purpose small example x = rnorm(10) y = rnorm(10) mvar2.LRT(x, y) ## Not run: ## 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.LRT(x,y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'mvar2.LRT'\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="")) ## End(Not run)
Given an univariate sample , it tests
using a test procedure by Shapiro and Wilk (1965). Actual computation of -value
is done via an approximation scheme by Royston (1992).
norm.1965SW(x)
norm.1965SW(x)
x |
a length- |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Shapiro SS, Wilk MB (1965). “An Analysis of Variance Test for Normality (Complete Samples).” Biometrika, 52(3/4), 591. ISSN 00063444.
Royston P (1992). “Approximating the Shapiro-Wilk W-test for non-normality.” Statistics and Computing, 2(3), 117–119. ISSN 0960-3174, 1573-1375.
## generate samples from several distributions x = stats::runif(28) # uniform y = stats::rgamma(28, shape=2) # gamma z = stats::rlnorm(28) # log-normal ## test above samples test.x = norm.1965SW(x) # uniform test.y = norm.1965SW(y) # gamma test.z = norm.1965SW(z) # log-normal
## generate samples from several distributions x = stats::runif(28) # uniform y = stats::rgamma(28, shape=2) # gamma z = stats::rlnorm(28) # log-normal ## test above samples test.x = norm.1965SW(x) # uniform test.y = norm.1965SW(y) # gamma test.z = norm.1965SW(z) # log-normal
Given an univariate sample , it tests
using a test procedure by Shapiro and Francia (1972), which is an approximation to Shapiro and Wilk (1965).
norm.1972SF(x)
norm.1972SF(x)
x |
a length- |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Shapiro SS, Francia RS (1972). “An Approximate Analysis of Variance Test for Normality.” Journal of the American Statistical Association, 67(337), 215–216. ISSN 0162-1459, 1537-274X.
## CRAN-purpose small example x = rnorm(10) norm.1972SF(x) # run the test ## generate samples from several distributions x = stats::runif(496) # uniform y = stats::rgamma(496, shape=2) # gamma z = stats::rlnorm(496) # log-normal ## test above samples test.x = norm.1972SF(x) # uniform test.y = norm.1972SF(y) # gamma test.z = norm.1972SF(z) # log-normal
## CRAN-purpose small example x = rnorm(10) norm.1972SF(x) # run the test ## generate samples from several distributions x = stats::runif(496) # uniform y = stats::rgamma(496, shape=2) # gamma z = stats::rlnorm(496) # log-normal ## test above samples test.x = norm.1972SF(x) # uniform test.y = norm.1972SF(y) # gamma test.z = norm.1972SF(z) # log-normal
Given an univariate sample , it tests
using a test procedure by Jarque and Bera (1980).
norm.1980JB(x, method = c("asymptotic", "MC"), nreps = 2000)
norm.1980JB(x, method = c("asymptotic", "MC"), nreps = 2000)
x |
a length- |
method |
method to compute |
nreps |
the number of Monte Carlo simulations to be run when |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Jarque CM, Bera AK (1980). “Efficient tests for normality, homoscedasticity and serial independence of regression residuals.” Economics Letters, 6(3), 255–259. ISSN 01651765.
Jarque CM, Bera AK (1987). “A Test for Normality of Observations and Regression Residuals.” International Statistical Review / Revue Internationale de Statistique, 55(2), 163. ISSN 03067734.
## generate samples from uniform distribution x = runif(28) ## test with both methods of attaining p-values test1 = norm.1980JB(x, method="a") # Asymptotics test2 = norm.1980JB(x, method="m") # Monte Carlo
## generate samples from uniform distribution x = runif(28) ## test with both methods of attaining p-values test1 = norm.1980JB(x, method="a") # Asymptotics test2 = norm.1980JB(x, method="m") # Monte Carlo
Given an univariate sample , it tests
using a test procedure by Urzua (1996), which is a modification of Jarque-Bera test.
norm.1996AJB(x, method = c("asymptotic", "MC"), nreps = 2000)
norm.1996AJB(x, method = c("asymptotic", "MC"), nreps = 2000)
x |
a length- |
method |
method to compute |
nreps |
the number of Monte Carlo simulations to be run when |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Urzúa CM (1996). “On the correct use of omnibus tests for normality.” Economics Letters, 53(3), 247–251. ISSN 01651765.
## generate samples from uniform distribution x = runif(28) ## test with both methods of attaining p-values test1 = norm.1996AJB(x, method="a") # Asymptotics test2 = norm.1996AJB(x, method="m") # Monte Carlo
## generate samples from uniform distribution x = runif(28) ## test with both methods of attaining p-values test1 = norm.1996AJB(x, method="a") # Asymptotics test2 = norm.1996AJB(x, method="m") # Monte Carlo
Given an univariate sample , it tests
using a test procedure by Gel and Gastwirth (2008), which is a robustified version Jarque-Bera test.
norm.2008RJB(x, C1 = 6, C2 = 24, method = c("asymptotic", "MC"), nreps = 2000)
norm.2008RJB(x, C1 = 6, C2 = 24, method = c("asymptotic", "MC"), nreps = 2000)
x |
a length- |
C1 |
a control constant. Authors proposed |
C2 |
a control constant. Authors proposed |
method |
method to compute |
nreps |
the number of Monte Carlo simulations to be run when |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Gel YR, Gastwirth JL (2008). “A robust modification of the Jarque–Bera test of normality.” Economics Letters, 99(1), 30–32. ISSN 01651765.
## generate samples from uniform distribution x = runif(28) ## test with both methods of attaining p-values test1 = norm.2008RJB(x, method="a") # Asymptotics test2 = norm.2008RJB(x, method="m") # Monte Carlo
## generate samples from uniform distribution x = runif(28) ## test with both methods of attaining p-values test1 = norm.2008RJB(x, method="a") # Asymptotics test2 = norm.2008RJB(x, method="m") # Monte Carlo
Given a multivariate sample , hypothesized mean
and covariance
, it tests
using the procedure by Liu et al. (2017).
sim1.2017Liu(X, mu0 = rep(0, ncol(X)), Sigma0 = diag(ncol(X)))
sim1.2017Liu(X, mu0 = rep(0, ncol(X)), Sigma0 = diag(ncol(X)))
X |
an |
mu0 |
a length- |
Sigma0 |
a |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Liu Z, Liu B, Zheng S, Shi N (2017). “Simultaneous testing of mean vector and covariance matrix for high-dimensional data.” Journal of Statistical Planning and Inference, 188, 82–93. ISSN 03783758.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) sim1.2017Liu(smallX) # run the test ## Not run: ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*10), ncol=10) counter[i] = ifelse(sim1.2017Liu(X)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'sim1.2017Liu'\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="")) ## End(Not run)
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) sim1.2017Liu(smallX) # run the test ## Not run: ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*10), ncol=10) counter[i] = ifelse(sim1.2017Liu(X)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'sim1.2017Liu'\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="")) ## End(Not run)
Given a multivariate sample , hypothesized mean
and covariance
, it tests
using the standard likelihood-ratio test procedure.
sim1.LRT(X, mu0 = rep(0, ncol(X)), Sigma0 = diag(ncol(X)))
sim1.LRT(X, mu0 = rep(0, ncol(X)), Sigma0 = diag(ncol(X)))
X |
an |
mu0 |
a length- |
Sigma0 |
a |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) sim1.LRT(smallX) # run the test ## Not run: ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(100*10), ncol=10) counter[i] = ifelse(sim1.LRT(X)$p.value < 0.05, 1, 0) print(paste("* iteration ",i,"/1000 complete...")) } ## print the result cat(paste("\n* Example for 'sim1.LRT'\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="")) ## End(Not run)
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) sim1.LRT(smallX) # run the test ## Not run: ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(100*10), ncol=10) counter[i] = ifelse(sim1.LRT(X)$p.value < 0.05, 1, 0) print(paste("* iteration ",i,"/1000 complete...")) } ## print the result cat(paste("\n* Example for 'sim1.LRT'\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="")) ## End(Not run)
Given a multivariate sample , hypothesized mean
and covariance
, it tests
using the procedure by Hyodo and Nishiyama (2018) in a similar fashion to that of Liu et al. (2017) for one-sample test.
sim2.2018HN(X, Y)
sim2.2018HN(X, Y)
X |
an |
Y |
an |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Hyodo M, Nishiyama T (2018). “A simultaneous testing of the mean vector and the covariance matrix among two populations for high-dimensional data.” TEST, 27(3), 680–699. ISSN 1133-0686, 1863-8260.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) sim2.2018HN(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(121*10), ncol=10) Y = matrix(rnorm(169*10), ncol=10) counter[i] = ifelse(sim2.2018HN(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'sim2.2018HN'\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=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) smallY = matrix(rnorm(10*3),ncol=3) sim2.2018HN(smallX, smallY) # run the test ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(121*10), ncol=10) Y = matrix(rnorm(169*10), ncol=10) counter[i] = ifelse(sim2.2018HN(X,Y)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'sim2.2018HN'\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=""))
Given a data such that its rows are
vectors in a probability simplex, i.e.,
test whether the data is uniformly distributed.
simplex.uniform(X, method)
simplex.uniform(X, method)
X |
an |
method |
(case-insensitive) name of the method to be used, including
|
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
## pseudo-uniform data generation N = 100 P = 4 X = matrix(stats::rnorm(N*P), ncol=P) for (n in 1:N){ x = X[n,] x = abs(x/sqrt(sum(x^2))) X[n,] = x^2 } ## run the tests simplex.uniform(X, "LRT") simplex.uniform(X, "lrtsym")
## pseudo-uniform data generation N = 100 P = 4 X = matrix(stats::rnorm(N*P), ncol=P) for (n in 1:N){ x = X[n,] x = abs(x/sqrt(sum(x^2))) X[n,] = x^2 } ## run the tests simplex.uniform(X, "LRT") simplex.uniform(X, "lrtsym")
Given a multivariate sample , it tests
using the procedure by Yang and Modarres (2017). Originally, it tests the goodness of fit
on the unit hypercube and modified for arbitrary rectangular domain.
unif.2017YMi( X, type = c("Q1", "Q2", "Q3"), lower = rep(0, ncol(X)), upper = rep(1, ncol(X)) )
unif.2017YMi( X, type = c("Q1", "Q2", "Q3"), lower = rep(0, ncol(X)), upper = rep(1, ncol(X)) )
X |
an |
type |
type of statistic to be used, one of |
lower |
length- |
upper |
length- |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Yang M, Modarres R (2017). “Multivariate tests of uniformity.” Statistical Papers, 58(3), 627–639. ISSN 0932-5026, 1613-9798.
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) unif.2017YMi(smallX) # run the test ## empirical Type 1 error ## compare performances of three methods niter = 1234 rec1 = rep(0,niter) # for Q1 rec2 = rep(0,niter) # Q2 rec3 = rep(0,niter) # Q3 for (i in 1:niter){ X = matrix(runif(50*10), ncol=50) # (n,p) = (10,50) rec1[i] = ifelse(unif.2017YMi(X, type="Q1")$p.value < 0.05, 1, 0) rec2[i] = ifelse(unif.2017YMi(X, type="Q2")$p.value < 0.05, 1, 0) rec3[i] = ifelse(unif.2017YMi(X, type="Q3")$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'unif.2017YMi'\n","*\n", "* Type 1 error with Q1 : ", round(sum(rec1/niter),5),"\n", "* Q2 : ", round(sum(rec2/niter),5),"\n", "* Q3 : ", round(sum(rec3/niter),5),"\n",sep=""))
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) unif.2017YMi(smallX) # run the test ## empirical Type 1 error ## compare performances of three methods niter = 1234 rec1 = rep(0,niter) # for Q1 rec2 = rep(0,niter) # Q2 rec3 = rep(0,niter) # Q3 for (i in 1:niter){ X = matrix(runif(50*10), ncol=50) # (n,p) = (10,50) rec1[i] = ifelse(unif.2017YMi(X, type="Q1")$p.value < 0.05, 1, 0) rec2[i] = ifelse(unif.2017YMi(X, type="Q2")$p.value < 0.05, 1, 0) rec3[i] = ifelse(unif.2017YMi(X, type="Q3")$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'unif.2017YMi'\n","*\n", "* Type 1 error with Q1 : ", round(sum(rec1/niter),5),"\n", "* Q2 : ", round(sum(rec2/niter),5),"\n", "* Q3 : ", round(sum(rec3/niter),5),"\n",sep=""))
Given a multivariate sample , it tests
using the procedure by Yang and Modarres (2017). Originally, it tests the goodness of fit
on the unit hypercube and modified for arbitrary rectangular domain. Since
this method depends on quantile information, every observation should strictly reside within
the boundary so that it becomes valid after transformation.
unif.2017YMq(X, lower = rep(0, ncol(X)), upper = rep(1, ncol(X)))
unif.2017YMq(X, lower = rep(0, ncol(X)), upper = rep(1, ncol(X)))
X |
an |
lower |
length- |
upper |
length- |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Yang M, Modarres R (2017). “Multivariate tests of uniformity.” Statistical Papers, 58(3), 627–639. ISSN 0932-5026, 1613-9798.
## CRAN-purpose small example smallX = matrix(runif(10*3),ncol=3) unif.2017YMq(smallX) # run the test ## empirical Type 1 error niter = 1234 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(runif(50*5), ncol=25) counter[i] = ifelse(unif.2017YMq(X)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'unif.2017YMq'\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=""))
## CRAN-purpose small example smallX = matrix(runif(10*3),ncol=3) unif.2017YMq(smallX) # run the test ## empirical Type 1 error niter = 1234 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(runif(50*5), ncol=25) counter[i] = ifelse(unif.2017YMq(X)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'unif.2017YMq'\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=""))
Any -sample method implies that it can be used for
a special case of
.
usek1d
lets any -sample tests
provided in this package be used with two univariate samples
and
.
usek1d(x, y, test.name, ...)
usek1d(x, y, test.name, ...)
x |
a length- |
y |
a length- |
test.name |
character string for the name of k-sample test to be used. |
... |
extra arguments passed onto the function |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
### compare two-means via anova and t-test ### since they coincide when k=2 x = rnorm(50) y = rnorm(50) ### run anova and t-test test1 = usek1d(x, y, "meank.anova") test2 = mean2.ttest(x,y) ## print the result cat(paste("\n* Comparison of ANOVA and t-test \n","*\n", "* p-value from ANOVA : ", round(test1$p.value,5),"\n", "* t-test : ", round(test2$p.value,5),"\n",sep=""))
### compare two-means via anova and t-test ### since they coincide when k=2 x = rnorm(50) y = rnorm(50) ### run anova and t-test test1 = usek1d(x, y, "meank.anova") test2 = mean2.ttest(x,y) ## print the result cat(paste("\n* Comparison of ANOVA and t-test \n","*\n", "* p-value from ANOVA : ", round(test1$p.value,5),"\n", "* t-test : ", round(test2$p.value,5),"\n",sep=""))
Any -sample method implies that it can be used for
a special case of
.
useknd
lets any -sample tests
provided in this package be used with two multivariate samples
and
.
useknd(X, Y, test.name, ...)
useknd(X, Y, test.name, ...)
X |
an |
Y |
an |
test.name |
character string for the name of k-sample test to be used. |
... |
extra arguments passed onto the function |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
## use 'covk.2007Schott' for two-sample covariance testing ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(useknd(X,Y,"covk.2007Schott")$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'covk.2007Schott'\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=""))
## use 'covk.2007Schott' for two-sample covariance testing ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=10) Y = matrix(rnorm(50*5), ncol=10) counter[i] = ifelse(useknd(X,Y,"covk.2007Schott")$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'covk.2007Schott'\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=""))
Given an univariate sample , it tests
.
var1.chisq(x, var0 = 1, alternative = c("two.sided", "less", "greater"))
var1.chisq(x, var0 = 1, alternative = c("two.sided", "less", "greater"))
x |
a length- |
var0 |
hypothesized variance |
alternative |
specifying the alternative hypothesis. |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
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 var1.chisq(x, alternative="l") ## Ha : var(x) <= 1 var1.chisq(x, alternative="t") ## Ha : var(x) =/=1 ## 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=""))
## CRAN-purpose small example x = rnorm(10) var1.chisq(x, alternative="g") ## Ha : var(x) >= 1 var1.chisq(x, alternative="l") ## Ha : var(x) <= 1 var1.chisq(x, alternative="t") ## Ha : var(x) =/=1 ## 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=""))
Given two univariate samples and
, it tests
.
var2.F(x, y, alternative = c("two.sided", "less", "greater"))
var2.F(x, y, alternative = c("two.sided", "less", "greater"))
x |
a length- |
y |
a length- |
alternative |
specifying the alternative hypothesis. |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
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) y = rnorm(10) var2.F(x, y, alternative="g") ## Ha : var(x) >= var(y) var2.F(x, y, alternative="l") ## Ha : var(x) <= var(y) var2.F(x, y, alternative="t") ## Ha : var(x) =/= var(y) ## 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=""))
## CRAN-purpose small example x = rnorm(10) y = rnorm(10) var2.F(x, y, alternative="g") ## Ha : var(x) >= var(y) var2.F(x, y, alternative="l") ## Ha : var(x) <= var(y) var2.F(x, y, alternative="t") ## Ha : var(x) =/= var(y) ## 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=""))
Given univariate samples , it tests
using the procedure by Bartlett (1937).
vark.1937Bartlett(dlist)
vark.1937Bartlett(dlist)
dlist |
a list of length |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Bartlett MS (1937). “Properties of Sufficiency and Statistical Tests.” Proceedings of the Royal Society of London. Series A, Mathematical and Physical Sciences, 160(901), 268–282. ISSN 00804630.
## CRAN-purpose small example small1d = list() for (i in 1:5){ # k=5 sample small1d[[i]] = rnorm(20) } vark.1937Bartlett(small1d) # run the test ## test when k=5 (samples) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = rnorm(50) } counter[i] = ifelse(vark.1937Bartlett(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'vark.1937Bartlett'\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=""))
## CRAN-purpose small example small1d = list() for (i in 1:5){ # k=5 sample small1d[[i]] = rnorm(20) } vark.1937Bartlett(small1d) # run the test ## test when k=5 (samples) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = rnorm(50) } counter[i] = ifelse(vark.1937Bartlett(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'vark.1937Bartlett'\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=""))
Given univariate samples , it tests
using the procedure by Levene (1960).
vark.1960Levene(dlist)
vark.1960Levene(dlist)
dlist |
a list of length |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Levene H (1960). “Robust tests for equality of variances.” In Contributions to Probability and Statistics: Essays in Honor of Harold Hotelling, 278–292. Stanford University Press, Palo Alto, California.
## CRAN-purpose small example small1d = list() for (i in 1:5){ # k=5 sample small1d[[i]] = rnorm(20) } vark.1960Levene(small1d) # run the test ## test when k=5 (samples) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = rnorm(50) } counter[i] = ifelse(vark.1960Levene(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'vark.1960Levene'\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=""))
## CRAN-purpose small example small1d = list() for (i in 1:5){ # k=5 sample small1d[[i]] = rnorm(20) } vark.1960Levene(small1d) # run the test ## test when k=5 (samples) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = rnorm(50) } counter[i] = ifelse(vark.1960Levene(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'vark.1960Levene'\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=""))
Given univariate samples , it tests
using the procedure by Brown and Forsythe (1974).
vark.1974BF(dlist)
vark.1974BF(dlist)
dlist |
a list of length |
a (list) object of S3
class htest
containing:
a test statistic.
-value under
.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
Brown MB, Forsythe AB (1974). “Robust Tests for the Equality of Variances.” Journal of the American Statistical Association, 69(346), 364–367. ISSN 0162-1459, 1537-274X.
## CRAN-purpose small example small1d = list() for (i in 1:5){ # k=5 sample small1d[[i]] = rnorm(20) } vark.1974BF(small1d) # run the test ## test when k=5 (samples) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = rnorm(50) } counter[i] = ifelse(vark.1974BF(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'vark.1974BF'\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=""))
## CRAN-purpose small example small1d = list() for (i in 1:5){ # k=5 sample small1d[[i]] = rnorm(20) } vark.1974BF(small1d) # run the test ## test when k=5 (samples) ## empirical Type 1 error niter = 1000 counter = rep(0,niter) # record p-values for (i in 1:niter){ mylist = list() for (j in 1:5){ mylist[[j]] = rnorm(50) } counter[i] = ifelse(vark.1974BF(mylist)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'vark.1974BF'\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=""))