user3002668
user3002668

Reputation: 11

Brokerage in social network. R script

I have got two observations of one network and nodes' attributes for the network (gender). I would like to identify nodes who served as brokers (mediators) for link formation between boys and girls. It means that there is no direct link between boy and girl during the first observation, but the 2-path exists. And during the second observation nodes create link. I'd like to identify that node which served as mediator during the first observation.

As I think it can be done by using quadratic adjacency matrix which shows the 2-path, but what should be done after I don't know, because only links between boy and girls are interesting.

Here is the beginning of my script:

library(network)
#Creating networks 

n11 <- c(0, 0, 1, 0, 0)
n12 <- c(0, 0, 1, 0, 0)
n13 <- c(1, 1, 0, 1, 1)
n14 <- c(0, 0, 1, 0, 1)
n15 <- c(0, 0, 0, 1, 0)
mat1 <- rbind (n11, n12, n13, n14, n15)
attr1 <- c(0, 1, 1, 1, 0) #0 - boy, 1 - girl
n21 <- c(0, 1, 1, 0, 0)
n22 <- c(1, 0, 1, 0, 0)
n23 <- c(1, 1, 0, 1, 1)    
n24 <- c(0, 0, 1, 0, 1)    
n25 <- c(0, 0, 1, 1, 0)    
mat2 <- rbind (n21, n22, n23, n24, n25)    
attr2 <- c(0, 1, 1, 1, 0) #0 - boy, 1 - girl

net1<-as.network(mat1)    
net2<-as.network(mat2)

#Setting actors' attributes    
set.vertex.attribute (net1, "gender", attr1)    
set.vertex.attribute (net2, "gender", attr2)

#Finding path length 2    
pl12 <- mat1 % * % mat1    
pl22 <- mat2 % * % mat2

Could you help me? Thank you very much!

Upvotes: 1

Views: 1157

Answers (1)

guest
guest

Reputation: 11

I would use the brokerage function in the sna package for R. SNA is part of the statnet suite of packages, so it will recognize the network objects you've already created in the 'network' package you are using. You will not need to find the path lengths or even set the vertex attributes.

library(sna)
brokerage(net1, attr1)

Looks like node #3 plays the most important brokerage role in period 1.

See brokerage package for more details and how to interpret the output: http://www.inside-r.org/packages/cran/sna/docs/brokerage

Upvotes: 1

Related Questions