# pingouin.multivariate_ttest

pingouin.multivariate_ttest(X, Y=None, paired=False)[source]

Hotelling T-squared test (= multivariate T-test)

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 one-sample test is performed where the null hypothesis is defined in Y. If Y is None, a one-sample 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 and Y must have exactly the same shape.

Returns
statspandas.DataFrame
• 'T2': T-squared value

• 'F': F-value

• 'df1': first degree of freedom

• 'df2': second degree of freedom

• 'p-val': p-value

multivariate_normality

Multivariate normality test.

ttest

Univariate T-test.

Notes

The Hotelling ‘s T-squared test [1] is the multivariate counterpart of the T-test.

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.

Examples

Two-sample independent Hotelling T-squared test

>>> import pingouin as pg
>>> 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


Two-sample paired Hotelling T-squared test

>>> pg.multivariate_ttest(X, Y, paired=True)
T2         F  df1  df2      pval
hotelling  4.468456  1.314252    3   15  0.306542


One-sample Hotelling T-squared 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.081281e-09