Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding critical values for the Pearson correlation coefficient

Tags:

r

I'd like to use R to find the critical values for the Pearson correlation coefficient.

This has proved difficult to find in search engines since the standard variable for the Pearson correlation coefficient is itself r. In turn, I'm finding a lot of r critical value tables (rather than how to find this by using the statistical package R).

I'm looking for a function that will provide output like the following:

enter image description here

I'm comfortable finding the correlation with:

cor(x,y)

However, I'd also like to find the critical values.

Is there a function I can use to enter n (or degrees of freedom) as well as alpha in order to find the critical value?

like image 263
Chuck Avatar asked Mar 26 '15 14:03

Chuck


People also ask

How do you find the critical value?

In statistics, critical value is the measurement statisticians use to calculate the margin of error within a set of data and is expressed as: Critical probability (p*) = 1 - (Alpha / 2), where Alpha is equal to 1 - (the confidence level / 100).

How do you find critical in R?

You can use the qt() function to find the critical value of t in R. The function gives the critical value of t for the one-tailed test. If you want the critical value of t for a two-tailed test, divide the significance level by two.

What is the value of the Pearson's correlation coefficient?

The Pearson correlation measures the strength of the linear relationship between two variables. It has a value between -1 to 1, with a value of -1 meaning a total negative linear correlation, 0 being no correlation, and + 1 meaning a total positive correlation.


1 Answers

The significance of a correlation coefficient, r, is determined by converting r to a t-statistic and then finding the significance of that t-value at the degrees of freedom that correspond to the sample size, n. So, you can use R to find the critical t-value and then convert that value back to a correlation coefficient to find the critical correlation coefficient.

critical.r <- function( n, alpha = .05 ) {
  df <- n - 2
  critical.t <- qt(alpha/2, df, lower.tail = F)
  critical.r <- sqrt( (critical.t^2) / ( (critical.t^2) + df ) )
  return(critical.r)
}
# Example usage: Critical correlation coefficient at sample size of n = 100
critical.r( 100 )
like image 72
Liz Page-Gould Avatar answered Oct 03 '22 20:10

Liz Page-Gould