0
$\begingroup$

I'm writing a statistical tool in Java. Here I'm calculation pearson correlation values (r). My next step is to validate if my correlation values are good enough to prove that my to variables are correlated. So I have two approaches in mind:

a) since I have the sample size = n and the correlation = r already calculated, I could use the these values to calculate the p-value and validate if p<alpha (level of significance) But for this approach I'm missing the formula for calculating the p-value

b) Since I'm planning to use a fixed alpha, I was thinking of precalculating the minimum r_min for given n. (e.g n=1 -> n=10000) and then check the calculated r against the precalculated r_min.

Does anyone know about a good solution for this Problem? I already found this but here as far as I see it, the library needs to recalculates the r with would take the performance down.

$\endgroup$

migrated from stackoverflow.com Jan 31 '13 at 14:33

This question came from our site for professional and enthusiast programmers.

  • 1
    $\begingroup$ I'll add that an issue with approach b is that it doesn't account for statistical significance. Intuitively, a dataset with two points would generate a line-of-best fit that has an r of exactly 1, but we both know such a value is not statistically significant. David Robinson's test statistic for inference on the correlation coefficient is probably the most valid approach. $\endgroup$ – AdamO Jan 31 '13 at 14:53
1
$\begingroup$

As described here, you can use the formula

enter image description here

to get a test statistic t, where n is the sample size and r is the calculated correlation. This test statistic t will follow a Student's t-distribution in the null hypothesis, so you can use it to compute a p-value.

However, note that this will not be as robust as using the traditional permutation or bootstrap p-value calculations for the significance of the correlation coefficient- that is, it assumes that both covariates have a normal distribution. If the data deviate from that assumption, this calculation might be unreliable.

$\endgroup$
  • $\begingroup$ you are right, with t and n I would be able to calculate the p-value, however I'm still missing an efficient implementation to calculate the actual p-value $\endgroup$ – Hellski Jan 30 '13 at 17:51
  • $\begingroup$ @Hellski: You could simply use TDistribution.cumulativeProbability here. $\endgroup$ – David Robinson Jan 30 '13 at 18:31
  • $\begingroup$ You could use the formula just under the one that David uses (on the page he points to) with your method 2 to calculate critical values using tools that already have the information on the t-distribution, then just hard code the resultsing correlations for each sample size for comparison. $\endgroup$ – Greg Snow Jan 31 '13 at 20:23
  • $\begingroup$ thank you all for your comments. I will think about the best way to fit my problem. But anyway the problem is solved. $\endgroup$ – Hellski Feb 18 '13 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.