Title: | Multivariate Normal Hypothesis Testing |
---|---|
Description: | Hypothesis testing of the parameters of multivariate normal distributions, including the testing of a single mean vector, two mean vectors, multiple mean vectors, a single covariance matrix, multiple covariance matrices, a mean and a covariance matrix simultaneously, and the testing of independence of multivariate normal random vectors. Huixuan, Gao (2005, ISBN:9787301078587), "Applied Multivariate Statistical Analysis". |
Authors: | Xifeng Zhang [aut, cre] |
Maintainer: | Xifeng Zhang <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.1.1 |
Built: | 2024-11-22 05:53:24 UTC |
Source: | https://github.com/astringency/mnormtest |
Test whether the covariance matrices of multiple multivariate normal populations are all equal. Suppose we have k populations, the null hypothesis is "H0: Sigma1 = Sigma2 = ... = Sigmak".
covTest.multi(X, label, alpha = 0.05, verbose = TRUE)
covTest.multi(X, label, alpha = 0.05, verbose = TRUE)
X |
The data matrix which is a matrix or data frame. |
label |
A vector of group labels. |
alpha |
The significance level. Default is 0.05. |
verbose |
A boolean value. Default is TRUE. If TRUE, the null hypothesis will be displayed. If FALSE, the test will be carried out silently. |
An object of class "testResult", which is a list with the following elements:
Conclusion |
The conclusion of the test. |
Stat |
A data frame containing the statistics, p value and critical value. |
SampMeanT |
The sample mean. |
SampMeanWithin |
The sample mean of each group. |
SdWithin |
The sample deviation of each group. |
SdWithinT |
The sample deviation within group. |
Df |
The degree of freedom. |
sampleSize |
The sample size of each group. |
d |
The Modified factor of the statistic. |
Xifeng Zhang
Huixuan, Gao. Applied Multivariate Statistical Analysis. Peking University Press, 2005: pp.88-89.
data(iris) chart <- iris[, 1:4] species <- iris[, 5] # carry out the test test1 <- covTest.multi(chart, species) test2 <- covTest.multi(chart, species, verbose = FALSE) # get the elements test1$Stat test1$SampMeanT test1$sampleSize
data(iris) chart <- iris[, 1:4] species <- iris[, 5] # carry out the test test1 <- covTest.multi(chart, species) test2 <- covTest.multi(chart, species, verbose = FALSE) # get the elements test1$Stat test1$SampMeanT test1$sampleSize
Test whether the covariance matrix is equal to a certain value. The null hypothesis is "H0: Sigma = Sigma0" or "H0: Sigma = sigma^2 * Sigma0".
covTest.single(data, Sigma0, ball = FALSE, alpha = 0.05, verbose = TRUE)
covTest.single(data, Sigma0, ball = FALSE, alpha = 0.05, verbose = TRUE)
data |
The data matrix which is a matrix or data frame. |
Sigma0 |
The covariance matrix when the null hypothesis is true. |
ball |
A boolean value. Default is FALSE. If FALSE, test whether the covariance matrix is Sigma0 (known), which means the null hypothesis is "H0: Sigma = Sigma0". If TRUE and the Sigma0 is a unit matrix, the Mauchly's ball test will be performed. If TRUE but Sigma0 (known) is not a unit matrix, the covariance matrix will be tested to see if it is sigma^2*Sigma0 (sigma^2 is unknown), which means the null hypothesis is "H0: Sigma = sigma^2 * Sigma0". |
alpha |
The significance level. Default is 0.05. |
verbose |
A boolean value. Default is TRUE. If TRUE, the null hypothesis will be displayed. If FALSE, the test will be carried out silently. |
An object of class "testResult", which is a list with the following elements: Return when ball is FALSE.
Conclusion |
The conclusion of the test. |
Stat |
A data frame containing the statistics, p value and critical value. |
SampMean |
The sample mean. |
SampA |
The sample deviation. |
Df |
The degree of freedom. |
Return when ball is TRUE
Conclusion |
The conclusion of the test. |
Stat |
A data frame containing the statistics, p value and critical value. |
SampMean |
The sample mean. |
SampA |
The sample deviation. |
sigma.hat |
The estimation of sigma^2. |
Df |
The degree of freedom. |
Xifeng Zhang
Huixuan, Gao. Applied Multivariate Statistical Analysis. Peking University Press, 2005: pp.83-88.
data(iris) X <- iris[, 1:4] # carry out the test test1 <- covTest.single(X, diag(1, 4)) test2 <- covTest.single(X, diag(1, 4), ball = TRUE) test3 <- covTest.single(X, diag(2, 4), ball = TRUE) test4 <- covTest.single(X, diag(1, 4), verbose = FALSE) # get the elements test1$Stat test2$Df test3$sigma.hat
data(iris) X <- iris[, 1:4] # carry out the test test1 <- covTest.single(X, diag(1, 4)) test2 <- covTest.single(X, diag(1, 4), ball = TRUE) test3 <- covTest.single(X, diag(2, 4), ball = TRUE) test4 <- covTest.single(X, diag(1, 4), verbose = FALSE) # get the elements test1$Stat test2$Df test3$sigma.hat
Test whether a set of multivariate normal random vectors are independent. The null hypothesis is "H0: The random vectors are independent of each other".
indTest.multi(data, subdim = FALSE, alpha = 0.05, verbose = TRUE)
indTest.multi(data, subdim = FALSE, alpha = 0.05, verbose = TRUE)
data |
The data matrix which is a matrix or data frame. Each column represents a random variable. |
subdim |
The dimensions of submatrices. The default is FALSE, which means the independence of all components of the random vector will be tested. |
alpha |
The significance level. Default is 0.05. |
verbose |
A boolean value. Default is TRUE. If TRUE, the null hypothesis will be displayed. If FALSE, the test will be carried out silently. |
An object of class "testResult", which is a list with the following elements:
Conclusion |
The conclusion of the test. |
Stat |
A data frame containing the statistics, p value and critical value. |
SampMean |
The sample mean. |
SampA |
The sample deviation. |
SampAii |
The sample deviation of submatrices. |
Df |
The degree of freedom. |
b |
The Modified factor of the statistic. |
Xifeng Zhang
Huixuan, Gao. Applied Multivariate Statistical Analysis. Peking University Press, 2005: pp.92-94.
data(iris) chart <- iris[, 1:4] # carry out the test test1 <- indTest.multi(chart) test2 <- indTest.multi(chart, subdim = c(2, 1, 1)) test3 <- indTest.multi(chart, verbose = FALSE) # get the elements test1$Stat test1$SampMean test2$SampAii
data(iris) chart <- iris[, 1:4] # carry out the test test1 <- indTest.multi(chart) test2 <- indTest.multi(chart, subdim = c(2, 1, 1)) test3 <- indTest.multi(chart, verbose = FALSE) # get the elements test1$Stat test1$SampMean test2$SampAii
Test whether the mean vectors and covariance matrices of multiple multivariate normal populations are all equal simultaneously. Suppose we have k populations, the null hypothesis is "H0: mu1 = mu2 = ... = muk and Sigma1 = Sigma2 = ... = Sigmak".
meancov.Test(X, label, alpha = 0.05, verbose = TRUE)
meancov.Test(X, label, alpha = 0.05, verbose = TRUE)
X |
The data matrix which is a matrix or data frame. |
label |
A vector of group labels. |
alpha |
The significance level. Default is 0.05. |
verbose |
A boolean value. Default is TRUE. If TRUE, the null hypothesis will be displayed. If FALSE, the test will be carried out silently. |
An object of class "testResult", which is a list with the following elements:
Conclusion |
The conclusion of the test. |
Stat |
A data frame containing the statistics, p value and critical value. |
SampMeanT |
The sample mean. |
SampMeanWithin |
The sample mean of each group. |
SdTotal |
The total sample deviation. |
SdWithin |
The sample deviation of each group. |
SdWithinT |
The sample deviation within group. |
Df |
The degree of freedom. |
sampleSize |
The sample size of each group. |
d |
The Modified factor of the statistic. |
Xifeng Zhang
Huixuan, Gao. Applied Multivariate Statistical Analysis. Peking University Press, 2005: pp.90-91.
data(iris) chart <- iris[, 1:4] species <- iris[, 5] # carry out the test test1 <- meancov.Test(chart, species) test2 <- meancov.Test(chart, species, verbose = FALSE) # get the elements test1$Stat test1$SampMeanT
data(iris) chart <- iris[, 1:4] species <- iris[, 5] # carry out the test test1 <- meancov.Test(chart, species) test2 <- meancov.Test(chart, species, verbose = FALSE) # get the elements test1$Stat test1$SampMeanT
Test whether the mean vectors of multiple multivariate normal populations are all equal when the covariance matrices are equal. Suppose we have k populations, the null hypothesis is that "H0: mu1 = mu2 = ... = muk". There are two approximations (Bartlett's chi2 and Rao's F) to compute the p-value and the critical value. The realized value of the Wilks Lambda statistic and its degrees of freedom are also provided. If you want to perform an exact test, consult the Wilks Lambda statistic quantile table yourself, depending on the realized value of the statistic and its degrees of freedom.
meanTest.multi(X, label, alpha = 0.05, verbose = TRUE)
meanTest.multi(X, label, alpha = 0.05, verbose = TRUE)
X |
The data matrix which is a matrix or data frame. |
label |
A vector of group labels. |
alpha |
The significance level. Default is 0.05. |
verbose |
A boolean value. Default is TRUE. If TRUE, the null hypothesis will be displayed. If FALSE, the test will be carried out silently. |
An object of class "testResult", which is a list with the following elements:
Conclusion |
The conclusion of the test. |
Stat |
A data frame containing the statistics, p value and critical value. |
SampMeanT |
The sample mean. |
SampMeanWithin |
The sample mean of each group. |
SdTotal |
The total sample deviation. |
SdBetween |
The sample deviation between group. |
SdWithin |
The sample deviation of each group. |
SdWithinT |
The sample deviation within group. |
Df |
The degree of freedom. |
sampleSize |
The sample size of each group. |
Xifeng Zhang
Huixuan, Gao. Applied Multivariate Statistical Analysis. Peking University Press, 2005: pp.80-83.
data(iris) chart <- iris[, 1:4] species <- iris[, 5] # carry out the test test1 <- meanTest.multi(chart, species) test2 <- meanTest.multi(chart, species, verbose = FALSE) # get the elements test1$Stat test1$SampMeanT test1$sampleSize
data(iris) chart <- iris[, 1:4] species <- iris[, 5] # carry out the test test1 <- meanTest.multi(chart, species) test2 <- meanTest.multi(chart, species, verbose = FALSE) # get the elements test1$Stat test1$SampMeanT test1$sampleSize
Test whether the mean vector of a single multivariate normal population is equal to a certain value when the population covariance matrix is known or unknown. The null hypothesis is that "H0: mu = mu0".
meanTest.single(data, mu0, Sigma0 = FALSE, alpha = 0.05, verbose = TRUE)
meanTest.single(data, mu0, Sigma0 = FALSE, alpha = 0.05, verbose = TRUE)
data |
The data matrix which is a matrix or data frame. |
mu0 |
The mean vector when the null hypothesis is true. |
Sigma0 |
The population covariance matrix. Default is FALSE which means the covariance matrix is unknown. |
alpha |
The significance level. Default is 0.05. |
verbose |
A boolean value. Default is TRUE. If TRUE, the null hypothesis will be displayed. If FALSE, the test will be carried out silently. |
An object of class "testResult", which is a list with the following elements:
Conclusion |
The conclusion of the test. |
Stat |
A data frame containing the statistics, p value and critical value. |
SampMean |
The sample mean. |
SampA |
The sample deviation. |
Df |
The degree of freedom. |
Xifeng Zhang
Huixuan, Gao. Applied Multivariate Statistical Analysis. Peking University Press, 2005: pp.66-68.
data(iris) X <- iris[, 1:4] mu0 <- c(5.8, 3.0, 4.3, 1.3) # carry out the test test1 <- meanTest.single(X, mu0) test2 <- meanTest.single(X, mu0, Sigma0 = diag(1, 4)) test3 <- meanTest.single(X, mu0, verbose = FALSE) # get the elements test1$Stat test1$SampMean test1$SampA test1$Df
data(iris) X <- iris[, 1:4] mu0 <- c(5.8, 3.0, 4.3, 1.3) # carry out the test test1 <- meanTest.single(X, mu0) test2 <- meanTest.single(X, mu0, Sigma0 = diag(1, 4)) test3 <- meanTest.single(X, mu0, verbose = FALSE) # get the elements test1$Stat test1$SampMean test1$SampA test1$Df
Test whether the mean vectors of two multivariate normal populations are equal when the covariance matrices are equal or unequal. The null hypothesis is that "H0: mu1 = mu2".
meanTest.two( data1, data2, alpha = 0.05, equal = TRUE, method = c("None", "Coupled", "Transformed"), verbose = TRUE )
meanTest.two( data1, data2, alpha = 0.05, equal = TRUE, method = c("None", "Coupled", "Transformed"), verbose = TRUE )
data1 |
A matrix or data frame of group 1. |
data2 |
A matrix or data frame of group 2. |
alpha |
The significance level. Default is 0.05. |
equal |
A boolean value. Default is TRUE. If TRUE, the covariance matrix is equal. If FALSE, the covariance matrix is not equal. |
method |
A string value. Default is "None". When equal is FALSE, you must choose a method in "Coupled" or "Transformed". Choose "Coupled" when the sample size of two groups is equal. Choose "Transformed" when the sample size of two groups is not equal. |
verbose |
A boolean value. Default is TRUE. If TRUE, the null hypothesis will be displayed. If FALSE, the test will be carried out silently. |
An object of class "testResult", which is a list with the following elements: Return when the param equal is TRUE.
Conclusion |
The conclusion of the test. |
Stat |
A data frame containing the statistics, p value and critical value. |
SampMean1 |
The sample mean of group 1. |
SampMean2 |
The sample mean of group 2. |
SampA1 |
The sample deviation of group 1. |
SampA2 |
The sample deviation of group 2. |
MixSampA |
The mixed sample deviation. |
Df |
The degree of freedom. |
Return when the param equal is FALSE and method is "Coupled".
Conclusion |
The conclusion of the test. |
Stat |
A data frame containing the statistics, p value and critical value. |
SampMeanC |
The sample mean of coupled data. |
SampAC |
The sample deviation of coupled data. |
Df |
The degree of freedom. |
dataC |
The coupled data. |
Return when the param equal is FALSE and method is "Transformed".
Conclusion |
The conclusion of the test. |
Stat |
A data frame containing the statistics, p value and critical value. |
SampMeanT |
The sample mean of transformed data. |
SampAT |
The sample deviation of transformed data. |
Df |
The degree of freedom. |
dataT |
The transformed data. Return when the param equal is FALSE and method is "Transformed". |
Xifeng Zhang
Huixuan, Gao. Applied Multivariate Statistical Analysis. Peking University Press, 2005: pp.76-80.
data(iris) X <- iris[1:50, 1:4] Y <- iris[51:100, 1:4] # carry out the test test1 <- meanTest.two(X, Y) test2 <- meanTest.two(X, Y, verbose = TRUE) test3 <- meanTest.two(X, Y, equal = FALSE, method = "Coupled") test4 <- meanTest.two(X, Y, equal = FALSE, method = "Transformed") # get the elements test1$Stat test1$SampMean1 test3$SampMeanC test4$dataT
data(iris) X <- iris[1:50, 1:4] Y <- iris[51:100, 1:4] # carry out the test test1 <- meanTest.two(X, Y) test2 <- meanTest.two(X, Y, verbose = TRUE) test3 <- meanTest.two(X, Y, equal = FALSE, method = "Coupled") test4 <- meanTest.two(X, Y, equal = FALSE, method = "Transformed") # get the elements test1$Stat test1$SampMean1 test3$SampMeanC test4$dataT