Table of Contents
The P-value of the correlation coefficient in R is a statistical measure that indicates the probability of obtaining a correlation coefficient at least as extreme as the one observed in a sample, assuming that the null hypothesis is true. It is a way to assess the strength and significance of the relationship between two variables in a dataset. A lower P-value suggests a stronger correlation between the variables, while a higher P-value indicates a weaker or non-existent relationship. In general, a P-value of less than 0.05 is considered statistically significant, meaning that the observed correlation is unlikely to have occurred by chance. Overall, the P-value of the correlation coefficient is a useful tool for determining the validity and reliability of a correlation analysis.
Find the P-value of Correlation Coefficient in R
The can be used to measure the linear association between two variables.
This correlation coefficient always takes on a value between -1 and 1 where:
- -1: Perfectly negative linear correlation between two variables.
- 0: No linear correlation between two variables.
- 1: Perfectly positive linear correlation between two variables.
To determine if a correlation coefficient is statistically significant, you can calculate the corresponding t-score and p-value.
The formula to calculate the t-score of a correlation coefficient (r) is:
t = r√n-2 / √1-r2
The p-value is calculated as the corresponding two-sided p-value for the t-distribution with n-2 degrees of freedom.
To calculate the p-value for a Pearson correlation coefficient in R, you can use the cor.test() function.
cor.test(x, y)
The following example shows how to use this function in practice.
Example: Calculate P-Value for Correlation Coefficient in R
The following code shows how to use the cor.test() function to calculate the p-value for the correlation coefficient between two variables in R:
#create two variables
x <- c(70, 78, 90, 87, 84, 86, 91, 74, 83, 85)
y <- c(90, 94, 79, 86, 84, 83, 88, 92, 76, 75)
#calculate correlation coefficient and corresponding p-value
cor.test(x, y)
Pearson's product-moment correlation
data: x and y
t = -1.7885, df = 8, p-value = 0.1115
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.8709830 0.1434593
sample estimates:
cor
-0.5344408
From the output we can see:
- The Pearson correlation coefficient is -0.5344408.
- The corresponding p-value is 0.1115.
Since the correlation coefficient is negative, it indicates that there is a negative linear relationship between the two variables.
However, since the p-value of the correlation coefficient is not less than 0.05, the correlation is not statistically significant.
#create two variables
x <- c(70, 78, 90, 87, 84, 86, 91, 74, 83, 85)
y <- c(90, 94, 79, 86, 84, 83, 88, 92, 76, 75)
#calculate p-value for correlation between x and y
cor.test(x, y)$p.value
[1] 0.1114995
The p-value for the correlation coefficient is 0.1114995.
This matches the p-value from the previous output.
Cite this article
stats writer (2024). What is the P-value of the correlation coefficient in R?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/what-is-the-p-value-of-the-correlation-coefficient-in-r/
stats writer. "What is the P-value of the correlation coefficient in R?." PSYCHOLOGICAL SCALES, 24 Jun. 2024, https://scales.arabpsychology.com/stats/what-is-the-p-value-of-the-correlation-coefficient-in-r/.
stats writer. "What is the P-value of the correlation coefficient in R?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/what-is-the-p-value-of-the-correlation-coefficient-in-r/.
stats writer (2024) 'What is the P-value of the correlation coefficient in R?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/what-is-the-p-value-of-the-correlation-coefficient-in-r/.
[1] stats writer, "What is the P-value of the correlation coefficient in R?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. What is the P-value of the correlation coefficient in R?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
