Skip to content

Compute critical value for pearson correlation #78

Description

@bradyrx

This might fit in xskillscore or climpred, but a useful calculation is the critical correlation coefficient (r) value for a Pearson correlation. This is the value that needs to be reached for statistical significance at a given alpha. It is computed by inverting the t statistic formula:

Screen Shot 2020-02-03 at 1 08 00 PM

A straight-forward approach:

from scipy.stats import t
p = 0.05 # two-tailed significance value
p = p /2 # formula here assuming one-tailed
df = 60
tval = t.ppf(p, df)
r_crit = tval / (np.sqrt(df + tval**2))

This aligns with values reported in various tables:
https://www.radford.edu/~jaspelme/statsbook/Chapter%20files/Table_of_Critical_Values_for_r.pdf
http://www.mun.ca/biology/scarr/Critical_Values_of_r.htm
https://www.statisticssolutions.com/table-of-critical-values-pearson-correlation/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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