Skip to content

Commit

Permalink
fix doc string issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sampan501 committed Sep 10, 2024
1 parent a753cb1 commit 767c106
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ Conditional Independence
:toctree: generated/

ConditionalDcorr
PartialCorr
PartialDcorr
PartialCorr
FCIT
KCI

Expand Down
2 changes: 1 addition & 1 deletion hyppo/conditional/pcorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class PartialCorr(ConditionalIndependenceTest):
-----
The statistic is computed as follows:
..math::
.. math::
r_{x, y ; z} = \frac{\rho_{xy} - \rho_{xz} \rho_{yz}}{\sqrt{(1 - \rho_{xz}^2)(1 - \rho_{yz}^2)}}
where :math:`\rho_{xy}` is the Pearson correlation coefficient between :math:`x` and
Expand Down
15 changes: 9 additions & 6 deletions hyppo/conditional/pdcorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,23 @@ class PartialDcorr(ConditionalIndependenceTest):
partial distance covariance is defined as
.. math::
\mathrm{PDcov}_n (x, y; z) &= \frac{1}{n(n-3)} \sum_{i\neq j}^n \left(P_{z^\perp}(x)\right)_{i,j} \left(P_{z^\perp}(y)\right)_{i,j}
\mathrm{PDcov}_n (x, y; z) = \frac{1}{n(n-3)} \sum_{i\neq j}^n \left(P_{z^\perp}(x)\right)_{i,j} \left(P_{z^\perp}(y)\right)_{i,j}
where
.. math::
P_{z^\perp}(x) &= C^x - \frac{(C^x\cdot C^z)}{ C^z \cdot C^z) C^z
P_{z^\perp}(x) = C^x - \frac{(C^x\cdot C^z)}{ C^z \cdot C^z) C^z
is the orthogonal proejction of :math:`C^x` onto the subspace orthogonal to :math:`C^z`.
The partial distance correlation is defined as
.. math::
\mathrm{PDcorr}_n (x, y; z) &= \frac{P_{z^\perp}(x)\cdot P_{z^\perp}(y)}{\abs{P_{z^\perp}(x)}\abs{P_{z^\perp}(y)}}
\mathrm{PDcorr}_n (x, y; z) = \frac{P_{z^\perp}(x)\cdot P_{z^\perp}(y)}{\abs{P_{z^\perp}(x)}\abs{P_{z^\perp}(y)}}
Equivalently, the partial distance correlation can be also defined as
.. math::
\mathrm{CDcorr}_n (x, y; z) &= \frac{R_{xy} - R_{xz} R_{yz}}{\sqrt{(1 - R_{xz}^2)(1 - R_{yz}^2)}}
\mathrm{CDcorr}_n (x, y; z) = \frac{R_{xy} - R_{xz} R_{yz}}{\sqrt{(1 - R_{xz}^2)(1 - R_{yz}^2)}}
where :math:`R_{xy}` is the unbiased distance correlation between :math:`x` and :math:`y`.
References
Expand Down Expand Up @@ -199,7 +202,7 @@ def test(


@jit(nopython=True, cache=True)
def _pdcov(distx, disty, distz): # pragma: no cover
def _pdcov(distx, disty, distz): # pragma: no cover
"""Calculate the PDcov test statistic"""
N = distx.shape[0]
denom = N * (N - 3)
Expand All @@ -223,7 +226,7 @@ def _pdcov(distx, disty, distz): # pragma: no cover


@jit(nopython=True, cache=True)
def _pdcorr(distx, disty, distz): # pragma: no cover
def _pdcorr(distx, disty, distz): # pragma: no cover
"""Calculate the PDcorr test statistic"""

distx = _center_distmat(distx, bias=False)
Expand Down
2 changes: 1 addition & 1 deletion hyppo/time_series/corrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LjungBox(TimeSeriesTest):
\mathrm{Ljung-Box}_n (x, y) = n(n+2)\sum_{j=1}^M \frac{
\rho^2(x[j:n], y[0:(n-j)])}{n-j}
where $\rho$ is the Pearson correlation coefficient.
where :math:`\rho` is the Pearson correlation coefficient.
The p-value returned is calculated either via chi-squared distribution or
using a permutation test.
Expand Down

0 comments on commit 767c106

Please sign in to comment.