Here, n is the number of students.
6. Now, we will look at the Spearman rank correlation coefficient table to find out the critical value for the significance level alpha.
7. If the value of is more than the critical value, we will reject the null hypothesis. Please note that in our case, the null hypothesis is there is no correlation between the marks obtained in subject 1 and subject 2. And the alternative hypothesis is that there is some correlation between the marks obtained in subject 1 and subject 2.
How to perform the Spearman rank correlation test using Python?
We can perform the Spearman rank correlation test using the spearmanr() function from the scipy.stats module in Python.
from scipy.stats import spearmanr subject1 = [50, 60, 75, 65, 60, 82, 85, 77, 80, 78] subject2 = [55, 65, 70, 78, 54, 92, 88, 73, 72, 80] t, p = spearmanr(subject1, subject2) print("Test statistic: ", t) print("p-value: ", p)
Here, the list subject1 contains the marks obtained by 10 students in subject 1. And the list subject2 contains the marks obtained by 10 students in subject 2. The output of the above program will be like the following:
Test statistic: 0.8449887057152897 p-value: 0.0020857965053343035
Here, the p-value is less than the significance level alpha = 0.05. So, we will reject the null hypothesis.






0 Comments