简体   繁体   中英

Spearman rank correlation with less than 4 observations?

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM