R:显著性检验
我试图使用我发现的一个函数来测试一个由igraph创建的对象的重要性 首先加载数据和库。然后,对数据执行聚类。最后,我使用我在网上找到的一个函数来计算聚类的重要性。然而,这是行不通的 有人能帮我理解为什么重要性测试的功能不起作用吗R:显著性检验,r,function,graph,nodes,R,Function,Graph,Nodes,我试图使用我发现的一个函数来测试一个由igraph创建的对象的重要性 首先加载数据和库。然后,对数据执行聚类。最后,我使用我在网上找到的一个函数来计算聚类的重要性。然而,这是行不通的 有人能帮我理解为什么重要性测试的功能不起作用吗 library(igraph) library(igraphdata) data(karate) cfg <- cluster_fast_greedy(karate) plot(cfg, karate) a = induced_subgraph(kara
library(igraph)
library(igraphdata)
data(karate)
cfg <- cluster_fast_greedy(karate)
plot(cfg, karate)
a = induced_subgraph(karate, cfg[[1]])
#community significance test (http://igraph.wikidot.com/community-detection-in-r)
community.significance.test <- function(graph, vs, ...) {
if (is.directed(graph)) stop("This method requires an undirected graph")
subgraph <- induced.subgraph(graph, vs)
in.degrees <- degree(subgraph)
out.degrees <- degree(graph, vs) - in.degrees
wilcox.test(in.degrees, out.degrees, ...)
}
#test the significance of the first community
aa = community.significance.test(karate,a)
Error in as.igraph.vs(graph, vids) :
'list' object cannot be coerced to type 'double'
库(igraph)
图书馆(igraphdata)
数据(空手道)
cfgvs
参数应该是顶点序列,而不是图形本身。调用函数的正确方法是community.signification.test(空手道,cfg[[1]])
(但在本例中,由于关系,您会遇到问题)。您可以使用
community.signity.test(空手道,cfg[[1]],exact=FALSE)关闭精确的pvalues)`谢谢!输出:带有连续性校正数据的Wilcoxon秩和检验:in.degrees和out.degrees W=312,p值=1.271e-06替代假设:真实位置偏移不等于0这意味着无效假设被拒绝,社区显著?这是我运行的代码:社区显著性检验(空手道,cfg[[1]],精确=假)@你对这个问题有什么想法吗?集群社区之间有内在联系吗?或者这些联系是任意的?OP问我第一个集群是否重要。对你得到了p-value=1.271e-0
通常人们认为任何小于0.05的p都是显著的。