Hotelling's T^2-test

Install required packages

DescTools, mvtnorm

One-sample Hotelling’s \(T^{2}\)-test

Simulate data

Using HotellingsT2() from package DescTools


    Hotelling's one sample T2-test

data:  Y1
T.2 = 5.3252, df1 = 2, df2 = 13, p-value = 0.02045
alternative hypothesis: true location is not equal to c(-1,2)

Using anova.mlm()

Analysis of Variance Table

            Df Hotelling-Lawley approx F num Df den Df  Pr(>F)  
(Intercept)  1          0.81925   5.3252      2     13 0.02045 *
Residuals   14                                                  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Hotelling’s \(T^{2}\)-test for two independent samples

Using HotellingsT2() from package DescTools


    Hotelling's two sample T2-test

data:  Y12 by IV
T.2 = 23.24, df1 = 2, df2 = 37, p-value = 2.901e-07
alternative hypothesis: true location difference is not equal to c(0,0)

Using anova.mlm() or manova()

Analysis of Variance Table

            Df Hotelling-Lawley approx F num Df den Df    Pr(>F)    
(Intercept)  1           1.3742   25.423      2     37 1.130e-07 ***
IV           1           1.2562   23.240      2     37 2.901e-07 ***
Residuals   38                                                      
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
          Df Hotelling-Lawley approx F num Df den Df    Pr(>F)    
IV         1           1.2562    23.24      2     37 2.901e-07 ***
Residuals 38                                                      
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Hotelling’s \(T^{2}\)-test for two dependent samples

Simulate data

Using HotellingsT2() from package DescTools


    Hotelling's one sample T2-test

data:  DVdiff
T.2 = 6.0014, df1 = 2, df2 = 18, p-value = 0.01007
alternative hypothesis: true location is not equal to c(0,0)

Using anova.mlm()

Analysis of Variance Table

            Df Hotelling-Lawley approx F num Df den Df  Pr(>F)  
(Intercept)  1          0.66682   6.0014      2     18 0.01007 *
Residuals   19                                                  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Detach (automatically) loaded packages (if possible)

Get the article source from GitHub

R markdown - markdown - R code - all posts