data("group_by_individual")
data("times")
# subset GBI (to reduce run time of the example)
gbi <- gbi[,1:80]
## define to 2 x N x N network to hold two association matrices
networks <- array(0, c(2, ncol(gbi), ncol(gbi)))
## calculate network for first half of the time
networks[1,,] <- get_network(gbi, data_format="GBI",
association_index="SRI", times=times, start_time=0,
end_time=max(times)/2)
networks[2,,] <- get_network(gbi, data_format="GBI",
association_index="SRI", times=times,
start_time=max(times)/2, end_time=max(times))
## test if one predicts the other via a mantel test (must be loaded externally)
library(ape)
mantel.test(networks[1,,],networks[2,,])
## convert to igraph network and calculate degree of the first network
if (FALSE) {
library(igraph)
net <- graph.adjacency(networks[1,,], mode="undirected", diag=FALSE, weighted=TRUE)
deg_weighted <- graph.strength(net)
detach(package:igraph)
## alternatively package SNA can use matrix stacks directly
library(sna)
deg_weighted <- degree(networks,gmode="graph", g=c(1,2), ignore.eval=FALSE)
detach(package:sna)
}
Run the code above in your browser using DataLab