Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

igraph vs sna: can one do something well the other can't or does poorly?

Tags:

r

igraph

sna

When it comes to network analysis in R, I am a relatively familiar with igraph but not at all with sna.

My question are:

  1. Are these two libraries compatible? i.e. Can I apply an operation from sna to a graph created in igraph and vice versa?

  2. Are there tasks that are performed more efficiently in one package than in the another?

  3. Which library has a more comprehensible range of operations?

  4. Overall, are there any strong reasons to do network analysis in R using either igraph or sna ?

ps. Does any of the these packages allow for multilayer (multiplex) network analysis?

like image 276
rafa.pereira Avatar asked Jun 15 '17 23:06

rafa.pereira


1 Answers

My sort of big picture take on the differences between the two packages is that igraph is more geared toward graph theory and mathematical models of networks and sna is more geared toward statistical models of (primarily social) networks. The creators of igraph (I think) mostly have a background in computer sciences, while the sna people are sociologists and statisticians. I primarily work in sna (and related packages that comprise the statnet suite of packages -- I am in the social sciences), but use igraph often as well, sometimes within the same script.

To answer your specific questions:

1) No, they are not. Many of the functions in igraph have the same name in sna and this causes conflicts. An igraph graph cannot be used in an sna function. The package intergraph was created to make it easy to switch between sna and igraph. So I could send an igraph graph to an sna function by passing to to intergraph first -- e.g. sna::evcent(intergraph::asNetwork(g)), assuming g is an igraph network. If you use both together in a script, you need to specifically call out the package when running a function or load and unload as needed.

2) In my experience, I have not found one to be more efficient than the other. Both are well developed and maintained packages. I believe that igraph is a bit better suited for large graphs--it has some functions that are modified to save on computational time when run on large graphs. But I do not have direct experience here. Although I would say that igraph is generally better at visualizations.

3) I would say that neither has an edge in comprehensiveness. Both do all the main network analysis stuff (centrality, network topology). They differ in their more "advanced" features. See my general point--they are geared to overlapping but distinct issues in network analysis. There's a lot of stuff in sna that is not available in igraph (e.g. related to statistical inference, like QAP regression [netlm / netlogit] or network autocorrelation models [lnam]), and vice versa (community detection functions like cluster_fast_greedy, for example). sna is extended by a number of compatible packages that do things like latent space models and exponential random graph models.

4) Ceterius paribus, no. To me, the choice is primarily needs driven. If you are interested in statistical inference, you need to work in sna. If not, igraph generally serves. Based on the questions at stack overflow, igraph seems to be more popular, but that of course could be due to selection bias. For that reason alone, if I didn't need to statistically model networks, I would probably mostly use igraph. Again, both packages are great, serving overlapping, but slightly different needs.

Not sure what you mean by "multilayer network analysis" but both igraph and sna work with multiplex networks. You can certainly analyze multiplex network and multilevel networks in sna. (Here, multiplex meaning a networks with a variety of tie types (e.g. friendship and advice) and multilevel meaning either nested networks or multiple networks from the same population (the terminology is a bit confused at this point).) It depends on what you want to do, and often takes some wrangling, but it is possible to an extent.

like image 200
paqmo Avatar answered Sep 27 '22 22:09

paqmo