Calculation of assortativeness in igraph

I have a dataset as follows:

set.seed(123)
A = data.frame(rnorm(10),rnorm(10),rnorm(10),rnorm(10))

And then use the igraph package to make a network of the following:

inv<-cor(t(A))
inv[inv<0.5] <- 0
inv[inv==1] <- 0
g1 <- graph.adjacency(inv, mode = "undirected", diag=FALSE, weighted=TRUE)

Now, to calculate the sort factor g1,

assortativity (g1, types1, types2 = NULL, directed = TRUE)

Now my question is: how do I set the β€œtypes”, it says in the documentation, these are the values ​​of the vertices. What exactly is meant by this? I would like to calculate assortivity for any 5 vertex network. Can someone tell me how to do this?

+3
source share
1 answer

So, I think you want a nominal version of the sort. For instance.

V(g1)$foo <- sample(1:3, replace=TRUE, vcount(g1))
assortativity.nominal(g1, types=V(g1)$foo)
# [1] -0.2270916

Types must be integers starting with 1. See the documentation for more details.

+4
source

All Articles