There are actually two very important cases where we want to use Spearman instead of Pearson:
- We use Spearman if we have outliers; in this case, Pearson results can change a lot due to just a few abnormal values.
- The second case is if one or both variables are measured on an ordinal scale (when we can sort the variables, but can't specify their magnitude), for example, if we have education levels (these are not years of education—but education categories with an ordinal meaning: 2 means more educated than 1) and salaries. Because the ranks are used, and not the actual number, Spearman can handle these cases, whereas Pearson cannot. This is shown in the following example:
salary=c(10,50,45,87,69,100)educ_level=c(1,2,3,4,5,6) ...