Spearman correlation fails in ranking strings
2 views (last 30 days)
I would like to compute the correlation between two rankings. Namely, I have two ranked variables, say:
7.00124562206948 'DR CONGO'
and a money2 table:
0.123754360000000 'DR CONGO'
Now simply I would like to compare the two variables ranked country1 and country2 as:
but the following error occurs:
Check for missing argument or incorrect argument data type in call to function 'imag'.
Error in corr (line 192)
complexdata = ~(isreal(x) || all(imag(x(:))==0));
what am I doing wrong?
P.s. the rownames are the names of the country.
Jeff Miller on 11 Jan 2022
The first two inputs to the corr command have to be the numerical values that are to be correlated, so you will want something like
However, you have to make sure that the rows of the two tables correspond (e.g., first row of each table has BURUNDI, second row has CHAD, etc). Maybe you can do that with sortrows()