Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
计算R中多个研究的统计数据_R_P Value_Kolmogorov Smirnov - Fatal编程技术网

计算R中多个研究的统计数据

计算R中多个研究的统计数据,r,p-value,kolmogorov-smirnov,R,P Value,Kolmogorov Smirnov,我有一个数据集,我想在其中应用一些测试,比如KS two sample。因此,我试图找到一种算法,可以将KS双样本测试应用于所有样本。基本思想是: 假设我有一个包含以下观察结果的数据集: 1 2 3 4 Study1 9 1 2 6 Study2 5 6 7 8 Study3 4 3 2 1 Study4 8 7 6 5 Study5 1 3 5 7 Study6 2 4 6 8 Study7 1 3 6 9 Study8 2 4 7 1 Study9 2 5 8 4 Study1

我有一个数据集,我想在其中应用一些测试,比如KS two sample。因此,我试图找到一种算法,可以将KS双样本测试应用于所有样本。基本思想是:

假设我有一个包含以下观察结果的数据集:

       1 2 3 4
Study1 9 1 2 6
Study2 5 6 7 8
Study3 4 3 2 1
Study4 8 7 6 5
Study5 1 3 5 7
Study6 2 4 6 8
Study7 1 3 6 9
Study8 2 4 7 1
Study9 2 5 8 4
Study10 3 6 8 5
我可以将KS测试应用于每项研究,包括以下内容:

ks.test(as.numeric(as.vector(df[1,])),as.numeric(as.vector(df[1,])))
ks.test(as.numeric(as.vector(df[1,])),as.numeric(as.vector(df[2,])))
ks.test(as.numeric(as.vector(df[1,])),as.numeric(as.vector(df[3,])))
                                   ...
ks.test(as.numeric(as.vector(df[1,])),as.numeric(as.vector(df[10,])))
ks.test(as.numeric(as.vector(df[2,])),as.numeric(as.vector(df[1,])))
                                   ...
ks.test(as.numeric(as.vector(df[10,])),as.numeric(as.vector(df[10,])))
这将产生10x10个p值,我的目标是将其用作距离的度量


因此,我正在寻找一种算法,它可以对nxn个样本运行KS测试,然后在nxn矩阵中输出p值。

您正在寻找
外部

outer(1:10, 1:10, Vectorize(function(i,j) {ks.test(as.numeric(as.vector(df[i,])),as.numeric(as.vector(df[j,])))$p.value}))

我得到了这个错误:
dim中的错误(robj)警告是什么?所有50条都是相同的:
警告消息:1:在ks.test中(as.numeric(as.vector(df[I,])),as.numeric(as.vector(df[I,])[j,…:无法使用领带计算精确的p值
ah。抱歉-您应该选择p值。我修改了答案非常感谢!尽管错误仍然存在,但效果非常好