简体   繁体   English

Spearman等级相关性少于4个观察值?

[英]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). 我目前正在尝试同时使用X数据集和Y数据集运行Spearman等级相关性测试,两者均包含3行(个人)。 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. 我可以使用cor()运行Spearman并获取值,它们都是:-1,-。5,-5或1。这对我来说似乎不正确。.我没有0数据集。 However, when I use rcorr(), it gives me an error: 但是,当我使用rcorr()时,它给了我一个错误:

 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 ) 我正在将肠道菌斑(我的X )与代谢读数(我的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? 我应该首先使用Spearman排名相关性吗?

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. 这是因为只有3种观测值与等级关联可能只有6种情况。

If we hold our x constant as 1:3 , there are 6 possible rank values for y (read row-wise): 如果我们将x常数保持为1:3 ,则y有6个可能的等级值(逐行读取):

   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: 计算X和Y之间的每个相关性时,只有以下可能的返回值:

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. 由于重复两个,您将获得4个值。

So - it is mathematically possible to calculate, but it is not very useful in describing the distribution. 因此-在数学上可以计算,但在描述分布方面不是很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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