Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute critical value for pearson correlation #78

Open
bradyrx opened this issue Feb 3, 2020 · 0 comments
Open

Compute critical value for pearson correlation #78

bradyrx opened this issue Feb 3, 2020 · 0 comments

Comments

@bradyrx
Copy link
Owner

bradyrx commented Feb 3, 2020

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant