Skip to contents

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".

Usage

meanTest.single(data, mu0, Sigma0 = FALSE, alpha = 0.05, verbose = TRUE)

Arguments

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.

Value

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.

References

Huixuan, Gao. Applied Multivariate Statistical Analysis. Peking University Press, 2005: pp.66-68.

Author

Xifeng Zhang

Examples

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)
#> H0: mu = (5.8, 3, 4.3, 1.3)' when Sigma is unknown
# get the elements
test1$Stat
#>                  Value p.value   Critical.Value
#> Hotelling T2 244.22150                         
#> F             59.82607       0 2.43363344771214
test1$SampMean
#> Sepal.Length  Sepal.Width Petal.Length  Petal.Width 
#>     5.843333     3.057333     3.758000     1.199333 
test1$SampA
#>              Sepal.Length Sepal.Width Petal.Length Petal.Width
#> Sepal.Length   102.168333   -6.322667     189.8730    76.92433
#> Sepal.Width     -6.322667   28.306933     -49.1188   -18.12427
#> Petal.Length   189.873000  -49.118800     464.3254   193.04580
#> Petal.Width     76.924333  -18.124267     193.0458    86.56993
test1$Df
#>                         df
#> Hotelling T2 T2( 4 , 149 )
#> F             F( 4 , 146 )