pingouin.multivariate_ttest

pingouin.
multivariate_ttest
(X, Y=None, paired=False)[source] Hotelling Tsquared test (= multivariate Ttest)
 Parameters
 Xnp.array
First data matrix of shape (n_samples, n_features).
 Ynp.array or None
Second data matrix of shape (n_samples, n_features). If
Y
is a 1D array of shape (n_features), a onesample test is performed where the null hypothesis is defined inY
. IfY
is None, a onesample is performed against np.zeros(n_features). pairedboolean
Specify whether the two observations are related (i.e. repeated measures) or independent. If
paired
is True,X
andY
must have exactly the same shape.
 Returns
 statspandas DataFrame
Hotelling Tsquared test summary
'T2' : Tsquared value 'F' : Fvalue 'df1' : first degree of freedom 'df2' : second degree of freedom 'pval' : pvalue
See also
multivariate_normality
Multivariate normality test
ttest
Univariate Ttest.
Notes
Hotelling ‘s Tsquared test is the multivariate counterpart of the Ttest.
Rows with missing values are automatically removed using the
remove_na()
function.Tested against the R package Hotelling.
References
 1
Hotelling, H. The Generalization of Student’s Ratio. Ann. Math. Statist. 2 (1931), no. 3, 360–378.
 2
 3
https://cran.rproject.org/web/packages/Hotelling/Hotelling.pdf
Examples
Twosample independent Hotelling Tsquared test
>>> import pingouin as pg >>> data = pg.read_dataset('multivariate') >>> dvs = ['Fever', 'Pressure', 'Aches'] >>> X = data[data['Condition'] == 'Drug'][dvs] >>> Y = data[data['Condition'] == 'Placebo'][dvs] >>> pg.multivariate_ttest(X, Y) T2 F df1 df2 pval hotelling 4.229 1.327 3 32 0.282898
Twosample paired Hotelling Tsquared test
>>> pg.multivariate_ttest(X, Y, paired=True) T2 F df1 df2 pval hotelling 4.468 1.314 3 15 0.306542
Onesample Hotelling Tsquared test with a specified null hypothesis
>>> null_hypothesis_means = [37.5, 70, 5] >>> pg.multivariate_ttest(X, Y=null_hypothesis_means) T2 F df1 df2 pval hotelling 253.231 74.48 3 15 3.081281e09