# Testing signficance of correlation

I have been trying to study on how to test significance for a correlation coefficient. So far I have seen that we calculate a value t and then either use p-value or critical value from the t-table to determine its significance.

Now I confused regarding these t-table and p-value. Most of the t-tables I find online have values up to 30 and then there are large jumps, so what if I have a sample size of n=33, so how do I find the critical value at df=31. As for p-value I have found online calculators that do the calculation, but I can't seem to find the formula used to calculate it. How is this p-value calculated?

Also I am not clear with what exactly df is? why am I subtracting 2 from n? why not n?

Moving on, why are the alternative hypothesis always p not equal 0, why can't it be a one tailed test, with say p > 0, trying to prove that it is a positive correlation ? If I can do that, then how exactly do my steps change? Do I just halve the p-value ? What are the changes in steps if I use the critical value method ?

There are other places where I have seen the same questions were asked, but I am sorry I couldn't get myself clear with this topic from those, and as they were fairly old, I thought it will be best if I create a new question.

1. Tabled statistics are hold-overs from an era when electronic computers were not ubiquitous, and limited page space meant a limited selection of parameter values were included in printed tables. Today we generally ask our software to calculate p-values to arbitrary precision for specific parameter values (including df = 33 :). See for, example the pt() function in R.

2. The p-value for a t statistic is calculated by integrating over the probability function for the range one cares about. In testing Pearson's r, one frequently sees a two-tailed test of the null hypothesis $$\rho = 0$$ (the sample Pearson's correlation coefficient is $$r$$, and the corresponding population statistic about which you want to make an inference is $$\rho$$), against an alternative hypothesis of $$\rho \ne 0$$, which implies positive or negative values of $$t$$, so $$p = P(|T_{\text{df}}| \ge |t|) = 2\int_{- \infty}^{|t|}{f(x)\frac{d}{dx}}$$ (where $$f(x)$$ is Student's t probability distribution function). Statistical software may evaluate closed form analytic expressions of such integrals, integrate by quantitative methods, use some kind of iterative algorithm, etc. depending on the specific probability distribution function.

3. The degrees of freedom for this specific t test is $$n-2$$ because you lose a degree of freedom for each variable used to calculate Pearson's r.

4. You can perform two-sided tests of null hypotheses other than $$\rho = 0$$ (e.g., $$\rho = 0.2$$), but they become considerably more complex mathematically. You could test $$H_{0}: \rho \le 0$$, with $$H_{A}: \rho > 0$$ (or vice versa), but then instead $$p = P(T_{\text{df}} > t) = 1 - \int_{-\infty}^{t}{f(x)\frac{d}{dx}}$$ (alternately $$p = P(T_{\text{df}} < t) = \int_{-\infty}^{t}{f(x)\frac{d}{dx}}$$ when testing $$H_{0}: \rho \ge 0$$).

• thanks a lot for sharing the equation. However I am still a bit unclear of the reason for degrees of freedom. also if I do one-tailed test then how will my steps change if I try to the test using the critical value method ? Dec 24, 2018 at 17:38
• @rhemon19 When students are first taught about t tests, they are often taught that $\text{df} = n - 1$; that '$1$' comes from the \frac{1}{n} part of each observation that contributes to calculating the sample mean $\left(\bar{x} = \frac{\sum_{i}^{n}{x}}{n}\right)$. However, the t test statistic for Pearson's r entails two sample means, $\bar{x}$ and $\bar{y}$, and each variable's sample mean takes a separate degree of freedom. Dec 24, 2018 at 17:45
• @rhemon19 Also: If you find an answer worthwhile, please consider up-voting it by clicking the up arrow at its top left. Dec 24, 2018 at 17:47
• thanks for the reply again. df is a bit more clear now. Dec 25, 2018 at 18:15
• also I did up-vote but unfortunately as I dont have enough reputation it is not displayed publicly Dec 25, 2018 at 18:16