0
votes

I'm currently trying to run a spearman rank correlation test with both an X dataset and a Y dataset, both containing 3 rows (individuals). I can run the Spearman with cor() and get values, all of them being: -1, -.5, -5, or 1. This just doesn't seem right to me.. I don't have any 0s in the datasets. However, when I use rcorr(), it gives me an error:

 Error in rcorr(BPT2, y = FunT2, type = "spearman") : 
 must have >4 observations

I am comparing Bacterial Phyla in the gut (my X) to metabolic readouts (my Y)

So my questions:

  1. Are the results i'm getting accurate?

  2. Should I be using a Spearman Rank Correlation in the first place?

Thanks!

1
You should provide a reproducible example in the question if you want help troubleshooting code. If you are asking about a proper statistical analysis, that type of question belongs on Cross Validated, not Stack Overflow (If you ever use the statistics tag, that's a good sign you are probably at the wrong site as the tag description itself says.)MrFlick

1 Answers

0
votes

You are right that there are only four possible outputs. This is because there are only 6 scenarios that are possible for rank correlation with 3 observations.

If we hold our x constant as 1:3, there are 6 possible rank values for y (read row-wise):

   Var1 Var2 Var3
1     3    2    1
2     2    3    1
3     3    1    2
4     1    3    2
5     2    1    3
6     1    2    3

When you compute each correlation between X and Y, there are only the following possible returns:

apply(df, 1, function(x){cor(1:3, x)})

   1    2    3    4    5    6 
-1.0 -0.5 -0.5  0.5  0.5  1.0

Since two are repeated, you get 4 values.

So - it is mathematically possible to calculate, but it is not very useful in describing the distribution.