2.Part 2: Calculate brokerage and betweenneess centrality measures for one or more subsets of your network data, and write up the results and your interpretation of them. Option 2.B: Briefly describe the various brokerage positions of nodes in the network, identifying which actors are most central and which are least central. Interpret your results as best you can. Discuss (with any related evidence) whether or not the node behavior is in line with or violates expectations.
Brokerage: i.For total brokerage it is the same faces. JB, Bonaventure (below), Victor, and Gregory. they are centrally located in a pretty connected graph, but even in the structural gaps, they are still in key positions.
Betweenness: i. Centrality: JB and Bonaventure have the highest betweenness. JB is the go-to monk for the Young Turks on a lot of measures, so makes sense. Bonaventure is like a gatekeeper to the less connected Loyalists, particularly with the Outcasts. They have to go through him or Romaud to reach the outer edges of the Loyalists. ii. Centralization: 0.202, Makes sense this a pretty well connected graph with not too many lynch pin people. There’s usually multiple paths to take to get from one node to the other.
library(igraph)
## Warning: package 'igraph' was built under R version 4.1.2
##
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
##
## decompose, spectrum
## The following object is masked from 'package:base':
##
## union
library(statnet)
## Loading required package: tergm
## Loading required package: ergm
## Loading required package: network
##
## 'network' 1.17.1 (2021-06-12), part of the Statnet Project
## * 'news(package="network")' for changes since last version
## * 'citation("network")' for citation information
## * 'https://statnet.org' for help, support, and other information
##
## Attaching package: 'network'
## The following objects are masked from 'package:igraph':
##
## %c%, %s%, add.edges, add.vertices, delete.edges, delete.vertices,
## get.edge.attribute, get.edges, get.vertex.attribute, is.bipartite,
## is.directed, list.edge.attributes, list.vertex.attributes,
## set.edge.attribute, set.vertex.attribute
##
## 'ergm' 4.1.2 (2021-07-26), part of the Statnet Project
## * 'news(package="ergm")' for changes since last version
## * 'citation("ergm")' for citation information
## * 'https://statnet.org' for help, support, and other information
## 'ergm' 4 is a major update that introduces some backwards-incompatible
## changes. Please type 'news(package="ergm")' for a list of major
## changes.
## Loading required package: networkDynamic
##
## 'networkDynamic' 0.11.0 (2021-06-12), part of the Statnet Project
## * 'news(package="networkDynamic")' for changes since last version
## * 'citation("networkDynamic")' for citation information
## * 'https://statnet.org' for help, support, and other information
## Registered S3 method overwritten by 'tergm':
## method from
## simulate_formula.network ergm
##
## 'tergm' 4.0.2 (2021-07-28), part of the Statnet Project
## * 'news(package="tergm")' for changes since last version
## * 'citation("tergm")' for citation information
## * 'https://statnet.org' for help, support, and other information
##
## Attaching package: 'tergm'
## The following object is masked from 'package:ergm':
##
## snctrl
## Loading required package: ergm.count
##
## 'ergm.count' 4.0.2 (2021-06-18), part of the Statnet Project
## * 'news(package="ergm.count")' for changes since last version
## * 'citation("ergm.count")' for citation information
## * 'https://statnet.org' for help, support, and other information
## Loading required package: sna
## Loading required package: statnet.common
##
## Attaching package: 'statnet.common'
## The following object is masked from 'package:ergm':
##
## snctrl
## The following objects are masked from 'package:base':
##
## attr, order
## sna: Tools for Social Network Analysis
## Version 2.6 created on 2020-10-5.
## copyright (c) 2005, Carter T. Butts, University of California-Irvine
## For citation information, type citation("sna").
## Type help(package="sna") to get started.
##
## Attaching package: 'sna'
## The following objects are masked from 'package:igraph':
##
## betweenness, bonpow, closeness, components, degree, dyad.census,
## evcent, hierarchy, is.connected, neighborhood, triad.census
## Loading required package: tsna
##
## 'statnet' 2019.6 (2019-06-13), part of the Statnet Project
## * 'news(package="statnet")' for changes since last version
## * 'citation("statnet")' for citation information
## * 'https://statnet.org' for help, support, and other information
## unable to reach CRAN
library(network)
library(intergraph)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.7 ✔ dplyr 1.0.9
## ✔ tidyr 1.2.0 ✔ stringr 1.4.0
## ✔ readr 2.0.0 ✔ forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.1.2
## Warning: package 'tibble' was built under R version 4.1.2
## Warning: package 'tidyr' was built under R version 4.1.2
## Warning: package 'dplyr' was built under R version 4.1.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::as_data_frame() masks tibble::as_data_frame(), igraph::as_data_frame()
## ✖ purrr::compose() masks igraph::compose()
## ✖ tidyr::crossing() masks igraph::crossing()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::groups() masks igraph::groups()
## ✖ dplyr::lag() masks stats::lag()
## ✖ purrr::simplify() masks igraph::simplify()
library(blockmodeling)
## To cite package 'blockmodeling' in publications please use package
## citation and (at least) one of the articles:
##
## Žiberna, Aleš (2007). Generalized blockmodeling of valued networks.
## Social Networks 29(1), 105-126.
##
## Žiberna, Aleš (2008). Direct and indirect approaches to blockmodeling
## of valued networks in terms of regular equivalence. Journal of
## Mathematical Sociology 32(1), 57–84.
##
## Žiberna, Aleš (2014). Blockmodeling of multilevel networks. Social
## Networks 39, 46–61. https://doi.org/10.1016/j.socnet.2014.04.002.
##
## Žiberna, Aleš (2021). Generalized and Classical Blockmodeling of
## Valued Networks, R package version 1.0.5.
##
## To see these entries in BibTeX format, use 'print(<citation>,
## bibtex=TRUE)', 'toBibtex(.)', or set
## 'options(citation.bibtex.max=999)'.
##
## Attaching package: 'blockmodeling'
## The following object is masked from 'package:dplyr':
##
## recode
## The following object is masked from 'package:sna':
##
## sedist
library(concoR)
data(samplk)
samT1 <- samplk1
samT3 <- samplk3
write.csv(samT1, "~/Documents/Networks/samT1.csv", row.names = F)
write.csv(samT3, "~/Documents/Networks/samT3.csv", row.names = F)
data(sampson)
sam <- samplike
ig.sam <- intergraph::asIgraph(sam)
get.eigen<-function(net, attr=NULL){
#set attr="weight" if weighted network
eigen<-evcent(net)
mat<-as.matrix.network(net, attr=attr)
diag(mat)<-0
mat2<-mat%*%mat
rc<-diag(mat2)/rowSums(mat2)
dc<-1-rc
data.frame(name=net%v%"vertex.names",
eigen=eigen,
eigen.rc=eigen*rc,
eigen.dc=eigen*dc)
}
get.brokerage<-function(net, attr="attr"){
temp<-data.frame(brokerage(net, cl = net%v%"attr")$z.nli)
temp$name=net%v%"vertex.names"
mutate(temp, broker.tot = temp$t,
broker.coord = temp$w_I,
broker.itin = temp$w_O,
broker.rep = temp$b_IO,
broker.gate = temp$b_OI,
broker.lia = temp$b_O)
}
vcount(ig.sam)
ecount(ig.sam)
is.bipartite(sam)
is.directed(sam)
is.weighted(ig.sam)
vertex_attr_names(ig.sam)
edge_attr_names(ig.sam)
print(sam)
head(sam %v% "vertex.names")
head(sam %v% "group")
head(sam %e% "nominations")
summary(sam %e% "nominations")
igraph::triad.census(ig.sam)
sna::dyad.census(sam)
sna::triad.census(sam, mode="graph")
gtrans(sam)
isolates(sam)
transitivity(ig.sam, type="global")
transitivity(ig.sam, type="average")
V(ig.sam)[c(1:18)]
V(ig.sam)$name<-V(ig.sam)$vertex.names
transitivity(ig.sam, type="local", vids=V(ig.sam)[c("Basil","John Bosco", "Gregory")])
distances(ig.sam,"Winfrid","Elias", weights = NA)#weights=NA = any available edge weights are ignored. #Calculate distances between two nodes
all_shortest_paths(ig.sam,"Winfrid","Elias", weights=NA)$res # list shortest paths between 2 nodes
average.path.length(ig.sam,directed=T)#find average shortest path for network
#df creation
monk.nodes<-data.frame(name=sam%v%"vertex.names",
degree=sna::degree(sam,gmode="graph"),
degree.wt=strength(ig.sam),
bonpow=bonpow(sam),
betweenness=sna::betweenness(sam, gmode="graph"),
btwn.centlztn = sna::centralization(sam,FUN="betweenness",mode="graph"),
close=igraph::closeness(ig.sam),
close.centlztn = centr_clo(ig.sam)$centralization,
constraint=constraint(ig.sam),
bonpowi = igraph::power_centrality(ig.sam))
#add in degree and out degree
monk.nodes <- monk.nodes %>%
mutate(indegree=igraph::degree(ig.sam, mode="in", loops=FALSE),
outdegree=igraph::degree(ig.sam, mode="out", loops=FALSE))
monk.nodes<-full_join(monk.nodes,get.brokerage(sam, "name"), by="name")
print(head(monk.nodes), digits=2)
monk.nodes%>%
select(-name) %>%
gather() %>%
ggplot(aes(value)) +
geom_histogram(bins = 30) +
facet_wrap(~key, scales = "free") +
ggtitle("Monks Like/Dislike")
names(brokerage(sam, cl = monk.nodes$name))
head(brokerage(sam, cl = monk.nodes$name)$z.nli)
#add GF brokerage scores to nodes dataframe
temp<-data.frame(brokerage(sam, cl = monk.nodes$name)$z.nli)
temp<-monk.nodes %>%
mutate(broker.tot = temp$t,
broker.coord = temp$w_I,
broker.itin = temp$w_O,
broker.rep = temp$b_IO,
broker.gate = temp$b_OI,
broker.lia = temp$b_O)
library(corrr)
temp<-monk.nodes %>%
select(contains("degree"),starts_with("eigen"), bonpow, starts_with("close"), between, starts_with("broker"))%>%
correlate() %>%
rearrange()
fashion(temp)
rplot(temp)
```