diff --git a/docs/statlab_corr_spearman_rho.rst b/docs/statlab_corr_spearman_rho.rst index 89515386..5b912c27 100644 --- a/docs/statlab_corr_spearman_rho.rst +++ b/docs/statlab_corr_spearman_rho.rst @@ -61,15 +61,15 @@ Let :math:`(Y_{i1}, Y_{i2})` be a pair of random variables corresponding to the Let :math:`(R_{i1}, R_{i2})` be the rank of :math:`Y_{i1}` and the rank of :math:`Y_{i2}`. In the case of ties, one method is to assign the tied group with the average of unique ranks corresponding the tied group. For the :math:`i` th sample, let -:math:`s_1` be the number of observed values less than :math:`Y_{i1}`, -:math:`s_2` be the number of observed values equal to :math:`Y_{i1}`, -and :math:`s_3` be the number of observed values greater to :math:`Y_{i1}`. +:math:`S_1` be the number of observed values less than :math:`Y_{i1}`, +:math:`S_2` be the number of observed values equal to :math:`Y_{i1}`, +and :math:`S_3` be the number of observed values greater to :math:`Y_{i1}`. We can calculate the rank of a single sample as .. math:: :label: eq_rank - R_{i^*1} = s_1 + \frac{s_2+1}{2} = n - s3 - \frac{s_2-1}{2}. + R_{i^*1} = S_1 + \frac{S_2+1}{2} = n - S_3 - \frac{S_2-1}{2}. For a vector, ``pandas.DataFrame`` has the ``rank`` function with ``method='average'`` option to calculate rank as defined in :eq:`eq_rank`. In ``R``, that can be calculated using the ``rank`` function with ``ties.method='average'`` option. @@ -80,10 +80,10 @@ The Spearman's :math:`\rho` can be calculated as: .. math:: :label: eq_rho - \rho = \frac{\frac{1}{n}\sum_i R_{i1}R_{i2} - \frac{1}{4}(n+1)^2}{t_1 t_2}, + \rho = \frac{\frac{1}{n}\sum_i R_{i1}R_{i2} - \frac{1}{4}(n+1)^2}{s_1 s_2}, -where :math:`t_1 = \sum_i Y_{i1}^2 - \frac{1}{4}(n+1)^2`, -and :math:`t_2 = \sum_i Y_{i2}^2 - \frac{1}{4}(n+1)^2`. +where :math:`s_1 = \sum_i Y_{i1}^2 - \frac{1}{4}(n+1)^2`, +and :math:`s_2 = \sum_i Y_{i2}^2 - \frac{1}{4}(n+1)^2`. ************* Example - Group-1