network_groups
This is an old revision of the document!
Identifying groups of networks
# Network's characteristics and subgroups library(sna) # Faux Magnolia High School data library(ergm) data(faux.magnolia.high) summary(faux.magnolia.high) fmh <- as.sociomatrix(faux.magnolia.high) gplot(fmh, vertex.cex=0.5, arrowhead.cex=0.5)
round(gden(fmh),4)
[1] 9e-04
transivity
fmh2 <- fmh %*% fmh (denom <- sum(fmh2)-sum(diag(fmh2))) (num <- sum(fmh2 * fmh)) round(num/denom,3) round(gtrans(fmh),3)
> fmh2 <- fmh %*% fmh > (denom <- sum(fmh2)-sum(diag(fmh2))) [1] 3642 > (num <- sum(fmh2 * fmh)) [1] 1014 > round(num/denom,3) [1] 0.278 > round(gtrans(fmh),3) [1] 0.278
reciprocity
# knoke.infor network is given in Chapter 2, Section 1 library(sna) knoke.infor <- as.matrix(read.table("knoke-infor.txt",header=T)) rownames(knoke.infor) <- colnames(knoke.infor) (num <- sum(knoke.infor * t(knoke.infor))) (denom <- sum(knoke.infor)) round(num/denom,3) round(grecip(knoke.infor, measure="edgewise"),3)
# knoke.money network knoke.money <- as.matrix(read.table("knoke-money.txt",header=T)) rownames(knoke.money) <- colnames(knoke.money) # dyad and triad patterns in knoke-infor and knoke-money dyad.census(knoke.infor) dyad.census(knoke.money) triad.census(knoke.infor) triad.census(knoke.money)
> triad.census(knoke.infor) 003 012 102 021D 021U 021C 111D 111U 030T 030C 201 120D 120U 120C 210 300 [1,] 3 13 12 1 13 3 10 4 7 0 14 4 2 1 24 9 > triad.census(knoke.money) 003 012 102 021D 021U 021C 111D 111U 030T 030C 201 120D 120U 120C 210 300 [1,] 20 48 2 10 13 7 1 1 14 0 0 3 0 1 0 0
component.dist(knoke.money)
> component.dist(knoke.money) $membership [1] 1 2 3 4 5 6 7 3 3 8 $csize [1] 1 1 3 1 1 1 1 1 $cdist [1] 7 0 1 0 0 0 0 0 0 0
# Faux Magnolia High School data (Continued) components(fmh) fmh.comp <- component.dist(fmh) names(fmh.comp) table(fmh.comp$csize) head(fmh.comp$membership,100) grp2 <- (1:1461)[fmh.comp$membership=="2"] str(grp2) # Faux Magnolia High School data (Continued) fmh.clique <- clique.census(fmh, clique.comembership="bysize") names(fmh.clique) str(fmh.clique$cliques) core.list <- c(122,183,530,1143,1160) # fmh.clique$cliques[[5]] fmh.comp$membership[core.list] fmh[core.list,core.list] summary(sort(geodist(fmh)$gdist[122,])[2:439])[-4] # end
network_groups.1448328473.txt.gz · Last modified: 2015/11/24 09:57 by hkimscil