Skip to content

divide by zero encountered to calculate p-value when r==1 #453

@emoen

Description

@emoen

In correlation.py the function _correl_pvalue(r, nx, k=0) does not handle the case when r=1.0.

This results in:

lib/python3.12/site-packages/pingouin/effsize.py:152): RuntimeWarning: divide by zero encountered in arctanh
  z = np.arctanh(stat)  # R-to-z transform

lib/python3.12/site-packages/pingouin/correlation.py:68): RuntimeWarning: divide by zero encountered in scalar divide
  tval = r * np.sqrt(dof [/](https://file+.vscode-resource.vscode-cdn.net/) (1 - r**2))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions