简体   繁体   English

计算R中随机网络的r平方值

[英]Calculate the r-squared value for a random network in R

I created a set of random networks in R using the erdos-renyi algorithm. 我使用erdos-renyi算法在R中创建了一组随机网络。 However, I cannot find a function to calculate the R-squared (Pearson correlation coefficient) value of the graph. 但是,我找不到函数来计算图的R平方(皮尔森相关系数)值。 Fro example, if I use the function erdos renyi game in the igraph package to make my network 例如,如果我使用igraph软件包中的功能erdos renyi game来建立我的网络

erdos.renyi.game(281, 447, type = "gnm",m = 465, directed = FALSE)

How would I be able to calculate the R-squared value for this? 我将如何为此计算R平方值?

library(igraph)
library(intergraph)
library(sna)

# create the graphs
gs <- replicate(2,  
                sample_gnm(281, 447,m = 465, directed = FALSE),
                simplify = F) 
# sample_gnm is preferred to erdos.renyi.game now

# turn them into network objects
nets <- lapply(gs, asNetwork)

Now use gcor to get the correlation and qaptest to test the significance. 现在,使用gcor获得相关性,并使用qaptest检验其重要性。

gcor(nets, g1 = 1, g2 =2)
[1] 0.003537025
qaptest(nets, gcor, g1 = 1, g2 = 2)

QAP Test Results

Estimated p-values:
    p(f(perm) >= f(d)): 0.17 
p(f(perm) <= f(d)): 0.834 

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

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