statsmodels.stats.covariance.transform_corr_normal#
- statsmodels.stats.covariance.transform_corr_normal(corr, method, return_var=False, possdef=True, *, result_object=None)[source]#
Transform correlation matrix to be consistent at normal distribution
- Parameters:
- corrarray_like
correlation matrix, either Pearson, Gaussian-rank, Spearman, Kendall or quadrant correlation matrix
- method
str type of covariance matrix supported types are ‘pearson’, ‘gauss_rank’, ‘kendal’, ‘spearman’ and ‘quadrant’
- return_varbool
If true, then the asymptotic variance of the normalized correlation is also returned. The variance of the spearman correlation requires numerical integration which is calculated with scipy’s odeint.
- possdef
notimplementedyet Check whether resulting correlation matrix for positive semidefinite and return a positive semidefinite approximation if not.
- result_objectbool,
optional Flag controlling whether a
TransformCorrNormalResultNamedTuple is returned. Whenreturn_var=TrueaTransformCorrNormalResultis always returned; it holds the same two elements as the legacy tuple, so it unpacks and indexes identically. Whenreturn_var=Falsea bare correlation matrix is returned unlessresult_object=True, which yields aTransformCorrNormalResultwithvarset toNone.
- Returns:
TransformCorrNormalResultorndarrayWhen
return_var=True(orresult_object=True), a NamedTuple with fields:- corrndarray
correlation matrix, consistent with correlation for a multivariate normal distribution
- varndarray or None
asymptotic variance of the correlation.
Nonewhenreturn_varis False, since it is not computed in that case.
TransformCorrNormalResulthas the same length and contents as the plain(corr_n, var)tuple it replaces, so it unpacks and indexes identically. SeeTransformCorrNormalResult.When
return_var=Falseandresult_objectis not True, a bare correlation matrix is returned instead.
Notes
Pearson and Gaussian-rank correlation are consistent at the normal distribution and will be returned without changes.
The other correlation matrices are not guaranteed to be positive semidefinite in small sample after conversion, even if the underlying untransformed correlation matrix is positive (semi)definite. Croux and Dehon mention that nobs / k_vars should be larger than 3 for kendall and larger than 2 for spearman.
References
[1]Boudt, Kris, Jonathan Cornelissen, and Christophe Croux. “The Gaussian Rank Correlation Estimator: Robustness Properties.” Statistics and Computing 22, no. 2 (April 5, 2011): 471-83. https://doi.org/10.1007/s11222-011-9237-0.
[2]Croux, Christophe, and Catherine Dehon. “Influence Functions of the Spearman and Kendall Correlation Measures.” Statistical Methods & Applications 19, no. 4 (May 12, 2010): 497-515. https://doi.org/10.1007/s10260-010-0142-z.