hierarch.stats.studentized_covariance

hierarch.stats.studentized_covariance(x, y)

Studentized sample covariance between two variables.

Sample covariance between two variables divided by standard error of sample covariance. Uses a bias-corrected approximation of standard error. This computes an approximately pivotal test statistic.

Parameters:
x, y: numeric array-likes
Returns:
float64

Studentized covariance.

Examples

>>> x = np.array([[0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
...               [1, 2, 3, 4, 5, 2, 3, 4, 5, 6]])
>>> x.T
array([[0, 1],
       [0, 2],
       [0, 3],
       [0, 4],
       [0, 5],
       [1, 2],
       [1, 3],
       [1, 4],
       [1, 5],
       [1, 6]])
>>> studentized_covariance(x.T[:,0], x.T[:,1])
1.0039690353154482

This is approximately equal to the t-statistic.

>>> import scipy.stats as stats
>>> a = np.array([2, 3, 4, 5, 6])
>>> b = np.array([1, 2, 3, 4, 5])
>>> stats.ttest_ind(a, b, equal_var=False)[0]
1.0