Search
 
SCRIPT & CODE EXAMPLE
 

R

r: network randomization test igprah stakoverflow

# NETWORK RANDOMIZATION TEST
# TEST IF FEATURES ARE UNUSUAL

# Create Network
g <- graph_from_data_frame(edges, directed=FALSE)
gd = edge_density(g)

# Network Average path length
g.apl <-mean_distance(g, directed=FALSE)

# Create one random graph with the same number of nodes and edges as g
g.random <- erdos.renyi.game(n = gorder(g), p.or.m = gd, type = "gnp")

# Generate 1000 random graphs
gl <- vector('list',1000)

for(i in 1:1000){
  gl[[i]] <- erdos.renyi.game(n = gorder(g), p.or.m = gd, type = "gnp")
}

# Calculate average path length of 1000 random graphs
gl.apls <- unlist(lapply(gl, mean_distance, directed = FALSE))

# Plot the distribution of average path lengths
hist(gl.apls, xlim = range(c(1.5, 10)))
abline(v = g.apl, col = "red", lty = 3, lwd = 2)

# Calculate the proportion of graphs with an average path length lower than our observed
mean(gl.apls < g.apl)
Comment

PREVIOUS NEXT
Code Example
R :: how to increment dates inside a for loop in r 
R :: R concaat string and number 
R :: point estimates and prediction intervals in r 
R :: required in r 
R :: Edit axis labels R 
R :: Significance codes 
R :: how to add in dictionary in R 
R :: R new column t test p-value 
R :: SSL certificate problem in R 
R :: ways to examine model in r 
R :: how to get the r2 value in r 
R :: how to remove all attributes from a variables in r 
Rust :: hello world rust 
Rust :: rust value of pi 
Rust :: get length of string rust 
Rust :: rust implement clone for struct 
Rust :: rust repeat character x times 
Rust :: const generics in rust 
Rust :: count matches with regex 
Rust :: armanriazi•rust•borrowchecker•lifetime•static 
Rust :: rust convert binary data into ASCII text using Base64 RFC 4648. 
Rust :: rust create derive trait 
Rust :: gentoo rust stdlib 
Rust :: armanriazi•rust•concept•unrolling 
Rust :: rust•armanriazi•concept•nan 
Lua :: lua loop through table 
Lua :: open popup windows lua 
Lua :: roblox table.find() 
Lua :: wait() in lua 
Lua :: What is BreakJoints roblox? 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =