| Title: | Powerful Tests for Multivariate Normality |
|---|---|
| Description: | A simple informative powerful test (mvnTest()) for multivariate normality proposed by Zhou and Shao (2014) <doi:10.1080/02664763.2013.839637>, which combines kurtosis with Shapiro-Wilk test that is easy for biomedical researchers to understand and easy to implement in all dimensions. This package also contains some other multivariate normality tests including Fattorini's FA test (faTest()), Mardia's skewness and kurtosis test (mardia()), Henze-Zirkler's test (mhz()), Bowman and Shenton's test (msk()), Royston’s H test (msw()), and Villasenor-Alva and Gonzalez-Estrada's test (msw()). Empirical power calculation functions for these tests are also provided. In addition, this package includes some functions to generate several types of multivariate distributions mentioned in Zhou and Shao (2014). |
| Authors: | Yian Zhang [aut, cre], Ming Zhou [aut], Yongzhao Shao [aut] |
| Maintainer: | Yian Zhang <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.0.1 |
| Built: | 2026-06-01 08:55:48 UTC |
| Source: | https://github.com/cran/mvnormalTest |
Generate univariate or multivariate random sample for the Copula Generated Distributions.
copulas(n, p, c = "clayton", param, invF, ...)copulas(n, p, c = "clayton", param, invF, ...)
n |
number of rows (observations). |
p |
total number of columns (variables). |
c |
name of an Archimedean copula, choosing from " |
param |
number (numeric) specifying the copula parameter. |
invF |
inverse function (quantile function, e.g. |
... |
optional arguments passed to |
univariate () or multivariate () random sample.
Yan, J. (2007). Enjoy the joy of copulas: with a package copula. Journal of Statistical Software, 21(4), 1-21.
set.seed(12345) ## Generate 5X2 random sample matrix from Clayton(0.5, qnorm) ## copulas(n=50, p=2, c="clayton", param=0.5, invF=qnorm) ## Power calculation against bivariate (p=2) Clayton(0.5, qnorm) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a=0.05, n=50, p=2, B=100, FUN=copulas, c="clayton", param=0.5, invF=qnorm)set.seed(12345) ## Generate 5X2 random sample matrix from Clayton(0.5, qnorm) ## copulas(n=50, p=2, c="clayton", param=0.5, invF=qnorm) ## Power calculation against bivariate (p=2) Clayton(0.5, qnorm) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a=0.05, n=50, p=2, B=100, FUN=copulas, c="clayton", param=0.5, invF=qnorm)
It computes FA Test proposed by Fattorini (1986). This test would be more rotationally robust than other SWT tests such as Royston (1982) H test and the test proposed by Villasenor-Alva and Gonzalez-Estrada (2009). The p-value of the test statistic is computed based on a simulated null distribution of the statistic.
faTest(X, B = 1000)faTest(X, B = 1000)
X |
an |
B |
number of Monte Carlo simulations for null distribution, default is 1000 (increase B to increase the precision of p-value). |
Returns a list with two objects:
mv.testresults of the FA test for multivariate normality, i.e., test statistic, p-value, and multivariate normality summary (YES, if p-value>0.05).
uv.shapiroa dataframe with rows detailing univariate Shapiro-Wilk tests. Columns in the dataframe contain test statistics W, p-value,and univariate normality summary (YES, if p-value>0.05).
Fattorini, L. (1986). Remarks on the use of Shapiro-Wilk statistic for testing multivariate normality. Statistica, 46(2), 209-217.
Lee, R., Qian, M., & Shao, Y. (2014). On rotational robustness of Shapiro-Wilk type tests for multivariate normality. Open Journal of Statistics, 4(11), 964.
Shapiro, S. S., & Wilk, M. B. (1965). An analysis of variance test for normality (complete samples). Biometrika, 52(3/4), 591-611.
Royston, J. P. (1982). An extension of Shapiro and Wilk's W test for normality to large samples. Journal of the Royal Statistical Society: Series C (Applied Statistics), 31(2), 115-124.
Villasenor Alva, J. A., & Estrada, E. G. (2009). A generalization of Shapiro–Wilk's test for multivariate normality. Communications in Statistics—Theory and Methods, 38(11), 1870-1883.
Zhou, M., & Shao, Y. (2014). A powerful test for multivariate normality. Journal of applied statistics, 41(2), 351-363.
power.faTest, mvnTest, msk, mardia, msw, mhz
set.seed(12345) ## Data from gamma distribution ## X = matrix(rgamma(50*4,shape = 2),50) faTest(X, B=100) ## load the ubiquitous multivariate iris data ## ## (first 50 observations of columns 1:4) ## iris.df = iris[1:50, 1:4] faTest(iris.df, B=100)set.seed(12345) ## Data from gamma distribution ## X = matrix(rgamma(50*4,shape = 2),50) faTest(X, B=100) ## load the ubiquitous multivariate iris data ## ## (first 50 observations of columns 1:4) ## iris.df = iris[1:50, 1:4] faTest(iris.df, B=100)
Generate univariate or multivariate random sample for distribution with independent marginals such that .
denotes the distribution having independent marginal distributions and . This function can generate
multivariate random samples only from distribution or from both and .
IMMV(n, p, q = NULL, D1, D2 = NULL, D1.args = list(), D2.args = list())IMMV(n, p, q = NULL, D1, D2 = NULL, D1.args = list(), D2.args = list())
n |
number of rows (observations). |
p |
total number of columns (variables). |
q |
number of columns from distribution |
D1 |
random generation function for 1st distribution (e.g., |
D2 |
random generation function for 2nd distribution (e.g., |
D1.args |
a list of optional arguments passed to |
D2.args |
a list of optional arguments passed to |
Returns univariate () or multivariate () random sample matrix.
Zhou, M., & Shao, Y. (2014). A powerful test for multivariate normality. Journal of applied statistics, 41(2), 351-363.
Henze, N., & Zirkler, B. (1990). A class of invariant consistent tests for multivariate normality. Communications in statistics-Theory and Methods, 19(10), 3595-3617.
set.seed(12345) ## Generate 5X2 random sample matrix from IMMV(N(0,1),Beta(1,2)) ## IMMV(n=5, p=2, q=1, D1=rbeta, D1.args=list(shape1=1,shape2=2), D2=rnorm) ## Power calculation against bivariate (p=2) IMMV(Gamma(5,1)) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a=0.05, n=50, p=2, B=100, FUN=IMMV, D1=rgamma, D1.args=list(shape=5, rate=1)) ## Power calculation against bivariate (p=2) IMMV(N(0,1),Beta(1,2)) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a=0.05, n=50, p=2, B=100, FUN=IMMV, q=1, D1=rbeta, D1.args=list(shape1=1,shape2=2), D2=rnorm)set.seed(12345) ## Generate 5X2 random sample matrix from IMMV(N(0,1),Beta(1,2)) ## IMMV(n=5, p=2, q=1, D1=rbeta, D1.args=list(shape1=1,shape2=2), D2=rnorm) ## Power calculation against bivariate (p=2) IMMV(Gamma(5,1)) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a=0.05, n=50, p=2, B=100, FUN=IMMV, D1=rgamma, D1.args=list(shape=5, rate=1)) ## Power calculation against bivariate (p=2) IMMV(N(0,1),Beta(1,2)) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a=0.05, n=50, p=2, B=100, FUN=IMMV, q=1, D1=rbeta, D1.args=list(shape1=1,shape2=2), D2=rnorm)
It computes Mardia (1970)'s multivariate skewness and kurtosis statistics and their corresponding
p-value. Both p-values of skewness and kurtosis statistics should be greater than 0.05 to conclude
multivariate normality. The skewness statistic will be adjusted for sample size .
mardia(X, std = TRUE)mardia(X, std = TRUE)
X |
an |
std |
if |
Returns a list with two objects:
mv.testresults of the Mardia test, i.e., test statistic, p-value, and multivariate normality summary (YES, if both skewness and kurtosis p-value>0.05).
uv.shapiroa dataframe with rows detailing univariate Shapiro-Wilk tests. Columns in the dataframe contain test statistics W, p-value,and univariate normality summary (YES, if p-value>0.05).
Mardia, K. V. (1970). Measures of multivariate skewness and kurtosis with applications. Biometrika, 57(3), 519-530.
Shapiro, S. S., & Wilk, M. B. (1965). An analysis of variance test for normality (complete samples). Biometrika, 52(3/4), 591-611.
Doornik, J. A., & Hansen, H. (2008). An omnibus test for univariate and multivariate normality. Oxford Bulletin of Economics and Statistics, 70, 927-939.
Zhou, M., & Shao, Y. (2014). A powerful test for multivariate normality. Journal of applied statistics, 41(2), 351-363.
mvnTest, faTest, msw, msk, mhz, mvn
set.seed(12345) ## Data from gamma distribution X = matrix(rgamma(50*4,shape = 2),50) mardia(X) ## Data from normal distribution X = matrix(rnorm(50*4,mean = 2 , sd = 1),50) mardia(X) ## load the ubiquitous multivariate iris data ## ## (first 50 observations of columns 1:4) ## iris.df = iris[1:50, 1:4] mardia(iris.df)set.seed(12345) ## Data from gamma distribution X = matrix(rgamma(50*4,shape = 2),50) mardia(X) ## Data from normal distribution X = matrix(rnorm(50*4,mean = 2 , sd = 1),50) mardia(X) ## load the ubiquitous multivariate iris data ## ## (first 50 observations of columns 1:4) ## iris.df = iris[1:50, 1:4] mardia(iris.df)
It computes a multiviariate normality test based on a non-negative functional distance which was proposed by Henze and Zirkler (1990). Under the null hypothesis the test statistic is approximately log-normally distributed.
mhz(X)mhz(X)
X |
an |
Returns a list with two objects:
mv.testresults of the Henze-Zirkler test, i.e., test statistic, p-value, and multivariate normality summary (YES, if p-value>0.05).
uv.shapiroa dataframe with rows detailing univariate Shapiro-Wilk tests. Columns in the dataframe contain test statistics W, p-value,and univariate normality summary (YES, if p-value>0.05).
Henze, N., & Zirkler, B. (1990). A class of invariant consistent tests for multivariate normality. Communications in statistics-Theory and Methods, 19(10), 3595-3617.
Shapiro, S. S., & Wilk, M. B. (1965). An analysis of variance test for normality (complete samples). Biometrika, 52(3/4), 591-611.
Zhou, M., & Shao, Y. (2014). A powerful test for multivariate normality. Journal of applied statistics, 41(2), 351-363.
power.mhz, mvnTest, faTest, msw, msk, mardia, mvn
set.seed(12345) ## Data from gamma distribution X = matrix(rgamma(50*4,shape = 2),50) mhz(X) ## Data from normal distribution X = matrix(rnorm(50*4,mean = 2 , sd = 1),50) mhz(X) ## load the ubiquitous multivariate iris data ## ## (first 50 observations of columns 1:4) ## iris.df = iris[1:50, 1:4] mhz(iris.df)set.seed(12345) ## Data from gamma distribution X = matrix(rgamma(50*4,shape = 2),50) mhz(X) ## Data from normal distribution X = matrix(rnorm(50*4,mean = 2 , sd = 1),50) mhz(X) ## load the ubiquitous multivariate iris data ## ## (first 50 observations of columns 1:4) ## iris.df = iris[1:50, 1:4] mhz(iris.df)
It computes Bowman and Shenton (1975)'s test statistic (MSK) and its corresponding
p-value for multivariate normality. The statistic is calculated based on a combination of
multivariate skewness (MS) and kurtosis (MK) such that . For formulas of MS and MK,
please refer to Mardia (1970). The corresponding p-value of the statistic is computed based on a
simulated null distribution of MSK. The skewness statistic (MS) will be adjusted for sample size .
msk(X, B = 1000)msk(X, B = 1000)
X |
an |
B |
number of Monte Carlo simulations for null distribution, default is 1000 (increase B to increase the precision of p-value). |
Returns a list with two objects:
mv.testresults of the Bowman and Shenton test, i.e., test statistic, p-value, and multivariate normality summary (YES, if p-value>0.05).
uv.shapiroa dataframe with rows detailing univariate Shapiro-Wilk tests. Columns in the dataframe contain test statistics W, p-value,and univariate normality summary (YES, if p-value>0.05).
Bowman, K. O., & Shenton, L. R. (1975). Omnibus test contours for departures from normality based on and . Biometrika, 62(2), 243-250.
Shapiro, S. S., & Wilk, M. B. (1965). An analysis of variance test for normality (complete samples). Biometrika, 52(3/4), 591-611.
Mardia, K. V. (1970). Measures of multivariate skewness and kurtosis with applications. Biometrika, 57(3), 519-530.
Doornik, J. A., & Hansen, H. (2008). An omnibus test for univariate and multivariate normality. Oxford Bulletin of Economics and Statistics, 70, 927-939.
Zhou, M., & Shao, Y. (2014). A powerful test for multivariate normality. Journal of applied statistics, 41(2), 351-363.
power.msk, mvnTest, faTest, msw, mardia, mhz, mvn
set.seed(12345) ## Data from gamma distribution X = matrix(rgamma(50*4,shape = 2),50) msk(X, B=100) ## load the ubiquitous multivariate iris data ## ## (first 50 observations of columns 1:4) ## iris.df = iris[1:50, 1:4] msk(iris.df, B=100)set.seed(12345) ## Data from gamma distribution X = matrix(rgamma(50*4,shape = 2),50) msk(X, B=100) ## load the ubiquitous multivariate iris data ## ## (first 50 observations of columns 1:4) ## iris.df = iris[1:50, 1:4] msk(iris.df, B=100)
The SWT-based tests for multivariate normality including Royston's H test and the test proposed by Villasenor-Alva and Gonzalez-Estrada (2009).
msw(X)msw(X)
X |
an |
Returns a list with two objects:
mv.testa result table of multivariate normality tests,
including the name of the test, test statistic,
p-value, and multivariate normality summary (Yes, if p-value>0.05). Note that the test results
of Royston will not be reported if or and the test results
of Villasenor-Alva and Gonzalez-Estrada (VAGE) will not be reported if or .
uv.shapiroa dataframe with rows detailing univariate Shapiro-Wilk tests.
Columns in the dataframe contain test statistics W, p-value,and univariate normality summary (YES, if p-value>0.05).
If the number of variable is , only univariate Shapiro-wilk's test result will be produced.
Shapiro, S. S., & Wilk, M. B. (1965). An analysis of variance test for normality (complete samples). Biometrika, 52(3/4), 591-611.
Royston, J. P. (1982). An extension of Shapiro and Wilk's W test for normality to large samples. Journal of the Royal Statistical Society: Series C (Applied Statistics), 31(2), 115-124.
Villasenor Alva, J. A., & Estrada, E. G. (2009). A generalization of Shapiro–Wilk's test for multivariate normality. Communications in Statistics—Theory and Methods, 38(11), 1870-1883.
Lee, R., Qian, M., & Shao, Y. (2014). On rotational robustness of Shapiro-Wilk type tests for multivariate normality. Open Journal of Statistics, 4(11), 964.
power.mswR, power.mswV, mvnTest, faTest, msk, mardia, mhz, mvn, shapiro.test
set.seed(12345) ## Data from gamma distribution X = matrix(rgamma(50*4,shape = 2),50) msw(X) ## Data from normal distribution X = matrix(rnorm(50*4,mean = 2 , sd = 1),50) msw(X) ## load the ubiquitous multivariate iris data ## ## (first 50 observations of columns 1:4) ## iris.df = iris[1:50, 1:4] msw(iris.df)set.seed(12345) ## Data from gamma distribution X = matrix(rgamma(50*4,shape = 2),50) msw(X) ## Data from normal distribution X = matrix(rnorm(50*4,mean = 2 , sd = 1),50) msw(X) ## load the ubiquitous multivariate iris data ## ## (first 50 observations of columns 1:4) ## iris.df = iris[1:50, 1:4] msw(iris.df)
Generate univariate or multivariate random sample for the normal mixture distribution with density
, where is the column vector with all elements being 1,
for . has to satisfy in order to make the
covariance matrix meaningful.
MVNMIX(n, p, lambda, mu2, rho1 = 0, rho2 = 0)MVNMIX(n, p, lambda, mu2, rho1 = 0, rho2 = 0)
n |
number of rows (observations). |
p |
total number of columns (variables). |
lambda |
weight parameter to allocate the proportions of the mixture, |
mu2 |
is |
rho1 |
parameter in |
rho2 |
parameter in |
Returns univariate () or multivariate () random sample matrix.
Zhou, M., & Shao, Y. (2014). A powerful test for multivariate normality. Journal of applied statistics, 41(2), 351-363.
set.seed(12345) ## Generate 5X2 random sample matrix from MVNMIX(0.5,4,0,0) ## MVNMIX(n=5, p=2, lambda=0.5, mu2=4, rho1=0, rho2=0) ## Power calculation against bivariate (p=2) MVNMIX(0.5,4,0,0) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a=0.05, n=50, p=2, B=100, FUN=MVNMIX, lambda=0.5, mu2=4, rho1=0, rho2=0)set.seed(12345) ## Generate 5X2 random sample matrix from MVNMIX(0.5,4,0,0) ## MVNMIX(n=5, p=2, lambda=0.5, mu2=4, rho1=0, rho2=0) ## Power calculation against bivariate (p=2) MVNMIX(0.5,4,0,0) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a=0.05, n=50, p=2, B=100, FUN=MVNMIX, lambda=0.5, mu2=4, rho1=0, rho2=0)
A simple and powerful test for multivariate normality with a combination of multivariate
kurtosis (MK) and Shapiro-Wilk which was proposed by Zhou and Shao (2014). The p-value of the test
statistic () is computed based on a simulated null distribution of . Details see Zhou and Shao (2014).
mvnTest(X, B = 1000, pct = c(0.01, 0.99))mvnTest(X, B = 1000, pct = c(0.01, 0.99))
X |
an |
B |
number of Monte Carlo simulations for null distribution, default is 1000 (increase B to increase the precision of p-value). |
pct |
percentiles of MK to get |
Returns a list with two objects:
mv.testresults of the Zhou-Shao's test for multivariate normality , i.e., test statistic ,
p-value (under H0, i.e. multivariate normal, that is at least as extreme as the observed value), and multivariate normality summary (YES, if p-value>0.05).
uv.shapiroa dataframe with rows detailing univariate Shapiro-Wilk tests. Columns in the dataframe contain test statistics W, p-value,and univariate normality summary (YES, if p-value>0.05).
Zhou, M., & Shao, Y. (2014). A powerful test for multivariate normality. Journal of applied statistics, 41(2), 351-363.
Shapiro, S. S., & Wilk, M. B. (1965). An analysis of variance test for normality (complete samples). Biometrika, 52(3/4), 591-611.
power.mvnTest, msk, mardia, msw, faTest, mhz
set.seed(12345) ## Data from gamma distribution ## X = matrix(rgamma(50*4,shape = 2),50) mvnTest(X, B=100) ## load the ubiquitous multivariate iris data ## ## (first 50 observations of columns 1:4) ## iris.df = iris[1:50, 1:4] mvnTest(iris.df, B=100)set.seed(12345) ## Data from gamma distribution ## X = matrix(rgamma(50*4,shape = 2),50) mvnTest(X, B=100) ## load the ubiquitous multivariate iris data ## ## (first 50 observations of columns 1:4) ## iris.df = iris[1:50, 1:4] mvnTest(iris.df, B=100)
Empirical power calculation using the Fattorini's FA Test Statistic.
power.faTest(a, n, p, B = 1000, FUN, ...)power.faTest(a, n, p, B = 1000, FUN, ...)
a |
significance level ( |
n |
number of rows (observations). |
p |
number of columns (variables), |
B |
number of Monte Carlo simulations, default is 1000 (can increase B to increase the precision). |
FUN |
self-defined function for generate multivariate distribution. See example. |
... |
optional arguments passed to |
Returns a numeric value of the estimated empirical power (value between 0 and 1).
Fattorini, L. (1986). Remarks on the use of Shapiro-Wilk statistic for testing multivariate normality. Statistica, 46(2), 209-217.
set.seed(12345) ## Power calculation against bivariate (p=2) independent Beta(1, 1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## power.faTest(a = 0.05, n = 50, p = 2, B = 100, FUN=IMMV, D1=runif)set.seed(12345) ## Power calculation against bivariate (p=2) independent Beta(1, 1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## power.faTest(a = 0.05, n = 50, p = 2, B = 100, FUN=IMMV, D1=runif)
Empirical power calculation using the Henze-Zirkler Test Statistic.
power.mhz(a, n, p, B = 1000, FUN, ...)power.mhz(a, n, p, B = 1000, FUN, ...)
a |
significance level ( |
n |
number of rows (observations). |
p |
number of columns (variables), |
B |
number of Monte Carlo simulations, default is 1000 (can increase B to increase the precision). |
FUN |
self-defined function for generate multivariate distribution. See example. |
... |
optional arguments passed to |
Returns a numeric value of the estimated empirical power (value between 0 and 1).
Henze, N., & Zirkler, B. (1990). A class of invariant consistent tests for multivariate normality. Communications in statistics-Theory and Methods, 19(10), 3595-3617.
set.seed(12345) ## Power calculation against bivariate (p=2) independent Beta(1, 1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## power.mhz(a = 0.05, n = 50, p = 2, B = 100, FUN=IMMV, D1=runif)set.seed(12345) ## Power calculation against bivariate (p=2) independent Beta(1, 1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## power.mhz(a = 0.05, n = 50, p = 2, B = 100, FUN=IMMV, D1=runif)
Empirical power calculation using Bowman and Shenton Test Statistic.
power.msk(a, n, p, B = 1000, FUN, ...)power.msk(a, n, p, B = 1000, FUN, ...)
a |
significance level ( |
n |
number of rows (observations). |
p |
number of columns (variables), |
B |
number of Monte Carlo simulations, default is 1000 (can increase B to increase the precision). |
FUN |
self-defined function for generate multivariate distribution. See example. |
... |
optional arguments passed to |
Returns a numeric value of the estimated empirical power (value between 0 and 1).
Bowman, K. O., & Shenton, L. R. (1975). Omnibus test contours for departures from normality based on and . Biometrika, 62(2), 243-250.
set.seed(12345) ## Power calculation against bivariate (p=2) independent Beta(1, 1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## power.msk(a = 0.05, n = 50, p = 2, B = 100, FUN=IMMV, D1=runif)set.seed(12345) ## Power calculation against bivariate (p=2) independent Beta(1, 1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## power.msk(a = 0.05, n = 50, p = 2, B = 100, FUN=IMMV, D1=runif)
Empirical power calculation using Royston test statistic.
power.mswR(a, n, p, B = 1000, FUN, ...)power.mswR(a, n, p, B = 1000, FUN, ...)
a |
significance level ( |
n |
number of rows (observations). |
p |
number of columns (variables), |
B |
number of Monte Carlo simulations, default is 1000 (can increase B to increase the precision). |
FUN |
self-defined function for generate multivariate distribution. See example. |
... |
optional arguments passed to |
Returns a numeric value of the estimated empirical power (value between 0 and 1).
Royston, J. P. (1982). An extension of Shapiro and Wilk's W test for normality to large samples. Journal of the Royal Statistical Society: Series C (Applied Statistics), 31(2), 115-124.
set.seed(12345) ## Power calculation against bivariate (p=2) independent Beta(1, 1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## power.mswR(a = 0.05, n = 50, p = 2, B = 100, FUN=IMMV, D1=runif)set.seed(12345) ## Power calculation against bivariate (p=2) independent Beta(1, 1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## power.mswR(a = 0.05, n = 50, p = 2, B = 100, FUN=IMMV, D1=runif)
Empirical power calculation using VAGE test statistic.
power.mswV(a, n, p, B = 1000, FUN, ...)power.mswV(a, n, p, B = 1000, FUN, ...)
a |
significance level ( |
n |
number of rows (observations). |
p |
number of columns (variables), |
B |
number of Monte Carlo simulations, default is 1000 (can increase B to increase the precision). |
FUN |
self-defined function for generate multivariate distribution. See example. |
... |
optional arguments passed to |
Returns a numeric value of the estimated empirical power (value between 0 and 1).
Villasenor Alva, J. A., & Estrada, E. G. (2009). A generalization of Shapiro–Wilk's test for multivariate normality. Communications in Statistics—Theory and Methods, 38(11), 1870-1883.
set.seed(12345) ## Power calculation against bivariate (p=2) independent Beta(1, 1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## power.mswV(a = 0.05, n = 50, p = 2, B = 100, FUN=IMMV, D1=runif)set.seed(12345) ## Power calculation against bivariate (p=2) independent Beta(1, 1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## power.mswV(a = 0.05, n = 50, p = 2, B = 100, FUN=IMMV, D1=runif)
)Empirical power calculation using the Zhou-Shao's multivariate normality test Statistic .
power.mvnTest(a, n, p, B = 1000, pct = c(0.01, 0.99), FUN, ...)power.mvnTest(a, n, p, B = 1000, pct = c(0.01, 0.99), FUN, ...)
a |
significance level ( |
n |
number of rows (observations). |
p |
number of columns (variables), |
B |
number of Monte Carlo simulations, default is 1000 (can increase B to increase the precision). |
pct |
percentiles of MK to get c1 and c2 described in the reference paper,default is (0.01, 0.99). |
FUN |
self-defined function for generate multivariate distribution. See example. |
... |
optional arguments passed to |
Returns a numeric value of the estimated empirical power (value between 0 and 1).
Zhou, M., & Shao, Y. (2014). A powerful test for multivariate normality. Journal of applied statistics, 41(2), 351-363.
set.seed(12345) ## Power calculation against bivariate (p=2) independent Beta(1, 1) distribution ## ## at sample size n=50 for Tn at one-sided alpha = 0.05 ## power.mvnTest(a = 0.05, n = 50, p = 2, B = 100, pct = c(0.01, 0.99), FUN=IMMV, D1=runif)set.seed(12345) ## Power calculation against bivariate (p=2) independent Beta(1, 1) distribution ## ## at sample size n=50 for Tn at one-sided alpha = 0.05 ## power.mvnTest(a = 0.05, n = 50, p = 2, B = 100, pct = c(0.01, 0.99), FUN=IMMV, D1=runif)
Empirical power calculation using univariate Shapiro-Wilk test statistic.
power.usw(a, n, p = 1, B = 1000, FUN, ...)power.usw(a, n, p = 1, B = 1000, FUN, ...)
a |
significance level ( |
n |
number of rows (observations). |
p |
p=1 for univariate. |
B |
number of Monte Carlo simulations, default is 1000 (can increase B to increase the precision). |
FUN |
self-defined function for generate multivariate distribution. See example. |
... |
optional arguments passed to |
Returns a numeric value of the estimated empirical power (value between 0 and 1).
Shapiro, S. S., & Wilk, M. B. (1965). An analysis of variance test for normality (complete samples). Biometrika, 52(3/4), 591-611.
set.seed(12345) ## Power calculation against univariate (p=1) independent Beta(1, 1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## power.usw(a = 0.05, n = 50, p = 1, B = 100, FUN=IMMV, D1=runif)set.seed(12345) ## Power calculation against univariate (p=1) independent Beta(1, 1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## power.usw(a = 0.05, n = 50, p = 1, B = 100, FUN=IMMV, D1=runif)
Generate univariate or multivariate random sample for the spherically symmetric Pearson type II distribution.
PSII(n, p, s)PSII(n, p, s)
n |
number of rows (observations). |
p |
number of columns (variables). |
s |
shape parameter, |
Returns univariate () or multivariate () random sample matrix.
Kotz, S. (1975). Multivariate distributions at a cross road. In A Modern Course on Statistical Distributions in Scientific Work (pp. 247-270). Springer, Dordrecht.
Henze, N., & Zirkler, B. (1990). A class of invariant consistent tests for multivariate normality. Communications in statistics-Theory and Methods, 19(10), 3595-3617.
set.seed(12345) ## Generate 5X2 random sample matrix from PSII(s=1) ## PSII(n=5, p=2, s=1) ## Power calculation against bivariate (p=2) PSII(s=1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a = 0.05, n = 50, p = 2, B = 100, FUN = PSII, s = 1)set.seed(12345) ## Generate 5X2 random sample matrix from PSII(s=1) ## PSII(n=5, p=2, s=1) ## Power calculation against bivariate (p=2) PSII(s=1) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a = 0.05, n = 50, p = 2, B = 100, FUN = PSII, s = 1)
Generate univariate or multivariate random sample for the spherically symmetric Pearson type VII distribution.
PSVII(n, p, s)PSVII(n, p, s)
n |
number of rows (observations). |
p |
number of columns (variables). |
s |
shape parameter, |
Returns univariate () or multivariate () random sample matrix.
Kotz, S. (1975). Multivariate distributions at a cross road. In A Modern Course on Statistical Distributions in Scientific Work (pp. 247-270). Springer, Dordrecht.
Henze, N., & Zirkler, B. (1990). A class of invariant consistent tests for multivariate normality. Communications in statistics-Theory and Methods, 19(10), 3595-3617.
set.seed(12345) ## Generate 5X2 random sample matrix from PSVII(s=3) ## PSVII(n=5, p=2, s=3) ## Power calculation against bivariate (p=2) PSVII(s=3) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a = 0.05, n = 50, p = 2, B = 100, FUN = PSVII, s = 3)set.seed(12345) ## Generate 5X2 random sample matrix from PSVII(s=3) ## PSVII(n=5, p=2, s=3) ## Power calculation against bivariate (p=2) PSVII(s=3) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a = 0.05, n = 50, p = 2, B = 100, FUN = PSVII, s = 3)
Generate univariate or multivariate random sample for general spherically symmetric distributions.
SPH(n, p, D, ...)SPH(n, p, D, ...)
n |
number of rows (observations). |
p |
number of columns (variables). |
D |
random generation functions for some distributions (e.g., |
... |
optional arguments passed to |
Returns univariate () or multivariate () random sample matrix.
Chmielewski, M. A. (1981). Elliptically symmetric distributions: A review and bibliography. International Statistical Review/Revue Internationale de Statistique, 67-74.
Henze, N., & Zirkler, B. (1990). A class of invariant consistent tests for multivariate normality. Communications in statistics-Theory and Methods, 19(10), 3595-3617.
set.seed(12345) ## Generate 5X2 random sample matrix from SPH(Beta(1,1)) ## SPH(n=5, p=2, D=rbeta, shape1=1, shape2=1) ## Power calculation against bivariate (p=2) SPH(Beta(1,1)) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a=0.05, n=50, p=2, B=100, FUN=SPH, D=rbeta, shape1=1, shape2=1)set.seed(12345) ## Generate 5X2 random sample matrix from SPH(Beta(1,1)) ## SPH(n=5, p=2, D=rbeta, shape1=1, shape2=1) ## Power calculation against bivariate (p=2) SPH(Beta(1,1)) distribution ## ## at sample size n=50 at one-sided alpha = 0.05 ## # Zhou-Shao's test # power.mvnTest(a=0.05, n=50, p=2, B=100, FUN=SPH, D=rbeta, shape1=1, shape2=1)