Showing posts with label social network analysis. Show all posts
Showing posts with label social network analysis. Show all posts

Tuesday, March 25, 2014

Kazakh Arms Imports Visualized (Part 1)

I thought it would be fun to put together a graph that shows the arms suppliers for Kazakhstan in 2013 in a network form.  The data come from SIPRI and I put them into a simple association matrix.  I used the R Statnet package to make the data a network, and then just used plot features in R to make the graph look a little nicer. I think that this is a fun little visualization of where these arms are coming from.  Here's the graph:



The code to do this is pretty straightforward.  If you want the data in the text format, please email me.  The code is pasted below using "Pretty R."


library(statnet)
supplier <- read.table("supplier.txt")
kasnet2013.m <- as.matrix(supplier)
kaznet2013 <- as.network(kasnet2013.m,matrix.type="adjacency", directed = T)
 
vertsize <- supplier$Kazakhstan*.05+1
png("Kazakh_imports2013.png", height = 8, width=11, units="in", bg="transparent",
    res=600)
plot(kaznet2013, displaylabels=TRUE, displayisolates = FALSE,
     vertex.col=c("gray","gray","red","gray","gray", "red","sienna4"),
     vertex.cex = vertsize,
     main=list("Kazakstan Arms Suppliers 2013", col="sienna4"),
     sub=list("Size of Vertex represents Value of Arms from Country",
              cex= .9, col="sienna3"))
 
mtext("Data from SIPRI TIV Database", side = 2, cex=.75, col="dimgray")
dev.off()
Created by Pretty R at inside-R.org

Friday, September 14, 2012

A Love Hate Relationship with R is Born

I am interested in arms transfers.  I am also interested in networks. In my dissertation I am combining those two interests.  I think that I am looking at some really cool relationships.  This is well and good. However, to do this fun research stuff I have had to leave my comfort zone of STATA and work in R.  Now I am fighting through the twin troubles of learning new software (and a language to code in) and learning new models.

I did a preliminary round of study to make sure that I could do this analysis in an advanced statistics class last semester.  Over the summer R changed versions. The package I use to do my ERGM analysis broke.  That package was updated.  Then my code broke and nothing worked the past two weeks as I have tried to get my analysis done for my dissertation.

After hours of frustrated Googling, I found a note on a blog (that I can't find a link to now... arrrrrgh!) about R namespaces and needing to remove the igraph and statnet packages and reinstall statnet first in order for it to work correctly.  I did this (without reinstalling igraph, just to be sure).  Now things run.  Now I can actually do analysis and not debugging and firefighting with the software.

Enough of the hate. I love Rstudio.  After running through some model specifications last night I decided to try out the knitr package. Awesome.  I still have a lot to learn to make things into real good documents and documentation of my analyses, but you can check out this link to my output for my test models here.

And here is a network graph of France's (egocentric) arms network during the 1950s.  The network is created from the main world network.  The world network accounts for all arms transactions from 1950 to 1959.  The sociomatrix shows a 1 if state i sold weapons to state j at any point during the 10 year window.
Created Using R. Data come from SIPRI.

Wednesday, February 22, 2012

World Arms Network 1950 and 1975

I am starting work on my dissertation.  The first thing I needed to do was to get all of my arms transfer data into a form that I can work with it for network analysis.  That effort is going nicely.  I spent a little time today playing around with the graphs for the year 1950.  Here is the worldwide arms network for 1950:
I also ran a quick graph of the arms network in 1975.  The thing that jumps out is the difference in the number of states that are importing weapons.  The graph as an analytical tool is nearly useless given the crowded nature of the arms market.  This is why I have to utilize real Social Network Analysis tools to get at the questions I really want to answer.  Graphs are fun, though.