statsmodels.stats.multivariate_tools.cancorr#
- statsmodels.stats.multivariate_tools.cancorr(x1, x2, demean=True, standardize=False)[source]#
Canonical correlation coefficient between 2 arrays
- Parameters:
- x1, x2array_like, 2-D
Two 2-dimensional data arrays, observations in rows, variables in columns.
- demeanbool,
optional If demean is true, then the mean is subtracted from each variable.
- standardizebool,
optional If standardize is true, then each variable is demeaned and divided by its standard deviation. Rescaling does not change the canonical correlation coefficients.
- Returns:
- ccorr
ndarray, 1-D Canonical correlation coefficients, sorted from largest to smallest. Note, that these are the square root of the eigenvalues.
- ccorr
See also
cc_ranktestRank tests based on the smallest canonical correlations.
cc_statsMANOVA statistics based on the canonical correlations.
CCANot yet implemented.
Notes
This is a helper function for other statistical functions. It only calculates the canonical correlation coefficients and does not do a full canonical correlation analysis.
The canonical correlation coefficient is calculated with the generalized matrix inverse and does not raise an exception if one of the data arrays have less than full column rank.
The eigenvalues underlying the canonical correlations are mathematically guaranteed to be real and non-negative, but the generalized eigenvalue problem is solved numerically and can return eigenvalues with a small spurious complex part or a small negative real part. Such numerical noise is clipped to zero before taking the square root, so
ccorris always real-valued.