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
 stats
pandas.DataFrame
'T2'
: Tsquared value'F'
: Fvalue'df1'
: first degree of freedom'df2'
: second degree of freedom'pval'
: pvalue
 stats
See also
multivariate_normality
Multivariate normality test.
ttest
Univariate Ttest.
Notes
The Hotelling ‘s Tsquared test [1] is the multivariate counterpart of the Ttest.
Rows with missing values are automatically removed using the
remove_na()
function.Tested against the Hotelling R package.
References
 1
Hotelling, H. The Generalization of Student’s Ratio. Ann. Math. Statist. 2 (1931), no. 3, 360–378.
See also http://www.realstatistics.com/multivariatestatistics/
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.228679 1.326644 3 32 0.282898
Twosample paired Hotelling Tsquared test
>>> pg.multivariate_ttest(X, Y, paired=True) T2 F df1 df2 pval hotelling 4.468456 1.314252 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.230991 74.479703 3 15 3.081281e09