Synopsis

In this report we will analyze latest survailance data from our loyal agents in the New World, with plots and tables and figures, to estimate probability of rebellion in this region of our Empire.

Data review

Load needed libraries

library(ggplot2)
library(scales)
library(stringi)
library(pander)
library(igraph)

Loading data

Fist we will load our data from csv file and see a short summary

data <- read.csv("anonimized_rebels.csv")
pander(summary(data))
Alfa Bravo Charlie Delta Echo Foxtrot Golf
Min. :0.0000 Min. :0.00000 Min. :0.0000 Min. :0.00000 Min. :0.0000 Min. :0.00000 Min. :0.0000
1st Qu.:0.0000 1st Qu.:0.00000 1st Qu.:0.0000 1st Qu.:0.00000 1st Qu.:0.0000 1st Qu.:0.00000 1st Qu.:0.0000
Median :0.0000 Median :0.00000 Median :0.0000 Median :0.00000 Median :0.0000 Median :0.00000 Median :0.0000
Mean :0.2087 Mean :0.03937 Mean :0.2323 Mean :0.06693 Mean :0.3819 Mean :0.08268 Mean :0.2441
3rd Qu.:0.0000 3rd Qu.:0.00000 3rd Qu.:0.0000 3rd Qu.:0.00000 3rd Qu.:1.0000 3rd Qu.:0.00000 3rd Qu.:0.0000
Max. :1.0000 Max. :1.00000 Max. :1.0000 Max. :1.00000 Max. :1.0000 Max. :1.00000 Max. :1.0000

Graph of communities

Now we will compute matrix of interconnections of each community and build a graph of those communities

Mc <- t(data) %*% as.matrix(data)
Gc=graph.adjacency(Mc,mode="undirected",weighted=NULL,diag=FALSE)
V(Gc)$size=degree(Gc)*1.15 #because 1 is a small size for a node, I'm just multiplying it by 5
set.seed(6)
plot.igraph(Gc,layout=layout.fruchterman.reingold, vertex.label.cex = 0.8)

Graph of personal connections

Now we will visualize estimated personal connections in graph

Mp <- as.matrix(data) %*% t(data)

Gp=graph.adjacency(Mp,mode="undirected",weighted=NULL,diag=FALSE)
V(Gp)$size=degree(Gp)*0.15 #because 1 is a small size for a node, I'm just multiplying it by 5
set.seed(6)
plot.igraph(Gp,vertex.label=NA,layout=layout.fruchterman.reingold, vertex.label.cex = 0.8)

Analizing personal connections network

Closeness

Closeness metric tells us how easy this person can access all the other persons unsing communities connections

Gpc <- closeness(Gp, vids = V(Gp))
GpcI <- sort(Gpc, decreasing = T, index.return=TRUE)

Degree

Degree metric tells us how many possible connections thru communities person may have

Gpd <- degree(Gp)
GpdI <- sort(Gpd, decreasing = T, index.return=TRUE)

Betweenness

Betweenness metric tells us how many possible connections over this person may be established

Gpb <- betweenness(Gp, v = V(Gp), directed = F)
GpbI <- sort(Gpb, decreasing = T, index.return=TRUE)

Conclusions

This is a list of top 20 persons (over every metric) recommended to neutralize

GpM <- data.frame(as.integer(GpcI[[2]]-1), GpcI[1],as.integer(GpdI[[2]]-1), GpdI[1], as.integer(GpdI[[2]]-1), GpbI[1])
colnames(GpM) <- c("ID by closeness", "Value of closeness", 
                   "ID by degree", "Value of degree", 
                   "ID by betweenness", "Value of betweenness")
pander(head(GpM, 20))
ID by closeness Value of closeness ID by degree Value of degree ID by betweenness Value of betweenness
199 0.003831 199 283 199 4490
10 0.003195 10 235 10 2419
13 0.003195 13 224 13 2318
46 0.003195 46 224 46 1368
232 0.003175 58 215 58 1251
58 0.003135 92 215 92 1251
92 0.003135 193 215 193 1126
193 0.003135 235 207 235 849.1
235 0.002959 232 206 232 849.1
156 0.002841 156 174 156 849.1
253 0.002841 253 174 253 752
74 0.002809 74 157 74 513.2
176 0.002778 1 155 1 513.2
57 0.002747 50 155 50 480.4
223 0.002747 57 154 57 394.8
224 0.002747 223 154 223 354.5
1 0.002584 224 154 224 354.5
50 0.002584 176 148 176 264.2
12 0.002532 95 139 95 264.2
59 0.002532 47 119 47 264.2