###Simulate datasets with a dependent sample and directed networks
#For an example with an undependent sample and undirected networks see README
data1 <- dplyr::tibble(person = c("1","1","2","2","2","3","3","3","4","4","4","4","4","5","5"),
from = c("1","3","3","1","4","3","1","3","1","4","3","3","3","2","1"),
to = c("3","4","4","3","2","1","3","4","3","3","4","2","4","4","3"))
data2 <- dplyr::tibble(person = c("1","2","2","3","3","3","3","3","3","3","4","4","4","5","5","5"),
from = c("1","1","1","1","2","1","2","4","4","3","1","3","2","1","1","3"),
to = c("2","2","4","2","4","4","3","3","1","4","2","2","1","4","2","4"))
### Compare networks of data sets using CEN
Res <- CEN(data1, data2, noc=4, it=50, paired=TRUE, directed=TRUE, abs=TRUE,
test.edges=TRUE, edge=list(c(1,3),c(4,2),c(3,2)), p.adjust.methods= "none",
test.centrality=TRUE, centrality=c("Closeness", "Betweenness"), cen.nodes="all",
test.bridge.centrality=FALSE, bridge.centrality="all", brg.nodes=c(1,3),
communities=c("1","1","2","2"), useCommunities="all")
###See results
summary(Res)
print(Res)
Res$glstrinv.sep
Res$glstrinv.pval
Res$nwinv.real
Res$nwinv.pval
Res$einv.real
Res$einv.pvals
Res$diffcen.real
Res$diffcen.pval
###Plot results
plot(Res, what="network")
plot(Res, what="strength")
plot(Res, what="edge")
plot(Res, what="centrality")
Run the code above in your browser using DataLab