Software
Most network analysis programmes are restricted to simple undirected binary one-mode static networks. Nevertheless, as I hope the other sections of this site have shown, studying richer types of network data can enable us to uncover and study interesting organising principles as well as measuring networks more accurately. The lack of software programmes to analyse richer forms of network data is forcing many non-programming researchers to simplify their data and remove the richness. To fill this gap, tnet is a package written in the statistical software R that currently can analyse weighted networks, two-mode networks, and longitudinal networks (datasets with time-stamped ties).
To the best of my knowledge, there are no programmes that can both analyse the richer forms of network data and allow users to create their own functions. On the one hand, programmes like UCINET and Pajek have a small set of functions for weighted and two-mode networks, but they do not allow users to programme additional functions (Batagelj and Mrvar, 2007; Borgatti et al., 2002). Therefore, researchers proposing new measures must create stand-alone programmes to deal with a single aspect of weighted networks (e.g., Brandes, 2001; Newman, 2001; Opsahl et al., 2008; Opsahl and Panzarasa, 2009). On the other, a number of packages for analysing networks has been created within the open-source statistical programme R, notably the sna and statnet-packages (Butts, 2006; Handcock et al., 2003). These packages allow researchers to create additional functions on top of existing ones. This ability reduces the time spent on programming greatly, and let researchers focus on the contribution to the literature instead. For example, if someone has already written a function for identifying the shortest paths in a network, a researcher that would like to extend this measure can simply work on this code without programming the function from scratch. However, the sna and statnet-packages rely on the basic network-package for data structures to represent networks (Butts et al., 2008). This basic package does not have data classes for weighted, two-mode, and longitudinal networks. Therefore, to ease the development of new functions for these networks, a new platform is needed. tnet represent an attempt to create such a platform. Although it is a user-written package in R, it does not rely on the network-package.
Getting tnet
Compiled versions and the source code of tnet are available through the CRAN servers. If you are using the Windows version of R, you should be able to install tnet by going to the ‘Package’-menu in R, opening ‘Install package(s)’, selecting a server close to you, and then, choosing ‘tnet’ from the list. For specific details on how to install, update, and load tnet, see the installation-page.
Data structures
Network data is handled in an edgelist format in tnet. This is a rectangular format where each row is a tie. The edgelist format is more efficient when networks are sparse (the number of ties is much smaller than the number of nodes squared). The functions can also read one-/two-mode matrices with more than 4 nodes; however, these will automatically be converted to edgelists. Unlike other R-packages, tnet does not utilise special object classes. It simply use a data frame, which increase transparency and -hopefully- helps researchers understand which data is analysed.
For one-mode networks, the data frame should have three columns where the first column contains the sender or originator of the tie, the second column contains the receiver or target node of the tie, and the third column containing the tie weight. Do note that for undirected networks, each tie must be mentioned twice (once in each direction). Read more…
Two-mode networks should be represented as either a two- or three-column data frame where the first column contain the primary or top nodes, the second column contains the secondary or bottom nodes, and the optional third column containing tie weights. As weighted two-mode network can be confused with weighted one-mode networks, it is important to run as.tnet(net, type="weighted two-mode tnet") before using any analysis functions. Read more…
Longitudinal data should represented by a four column object. The columns correspond to (1) the timing using the following format surrounded by quotes: “YYYY-MM-DD HH:MM:SS”, (2) the sender or originator of the tie, (3) the receiver or target node of the tie, and (4) the tie weight. Unlike the one-/two-mode formats, the tie weight can take negative values, which signal a weakening of the tie. Read more…
Implemented Functions
The various network measures are covered in their respective sections of this website and the R-documentation. Additionally, there are a number of functions for transferring network data between programmes available.
Datasets
For the convenience of tnet users, I have collected a number of network datasets that were available on the Internet, and made them conform to the required standard. Please do cite the mentioned reference if you use a dataset. It is possible to downloaded the networks in their native form and transformed versions. For example, the Facebook-like Social Network is available as a longitudinal one-mode network (native form) and as a static one-mode network. Read more…
Licensing
tnet, as the information on this blog, is published under the Creative Commons Attribution-Noncommercial 3.0-lisence. This means that you are free to:
· share (copy, distribute and transmit)
· remix (adapt)
under the following conditions:
· attribution (you must cite or link to it)
· noncommercial (you may not use it for commercial purposes; contact me).
References
Barrat, A., Barthelemy, M., Pastor-Satorras, R., Vespignani, A., 2004. The architecture of complex weighted networks. Proceedings of the National Academy of Sciences 101 (11), 3747-3752. arXiv:cond-mat/0311416
Batagelj, V., Mrvar, A., 2007. Pajek: Program for Large Network Analysis: version 1.20. http://pajek.imfm.si/.
Borgatti, S. P., Everett, M. G., Freeman, L. C., 2002. Ucinet for Windows: Software for Social Network Analysis. Analytic Technologies, Harvard, MA.
Brandes, U., 2001. A Faster Algorithm for Betweenness Centrality. Journal of Mathematical Sociology 25, 163-177.
Butts, C. T., 2006. sna-package: Package for Social Network Analysis. R package version 1.4.
Butts, C. T., Handcock, M. S., Hunter, D. R., 2008. network: Classes for Relational Data. http://statnet.org/.
Dijkstra, E. W., 1959. A note on two problems in connexion with graphs. Numerische Mathematik 1, 269-271.
Freeman, L. C., 1978. Centrality in social networks: Conceptual clarification. Social Networks 1, 215-239.
Handcock, M. S., Hunter, D. R., Butts, C. T., Goodreau, S. M., Morris, M., 2003. statnet: Software Tools for the Statistical Modeling of Network Data. http://statnetproject.org.
Newman, M. E. J., 2001. Scientific collaboration networks. II. Shortest paths, weighted networks, and centrality. Physical Review E 64, 016132.
Opsahl, T., 2013. Triadic closure in two-mode networks: Redefining the global and local clustering coefficients. Social Networks 35, doi:10.1016/j.socnet.2011.07.001.
Opsahl, T., Agneessens, F., Skvoretz, J., 2010. Node centrality in weighted networks: Generalizing degree and shortest paths. Social Networks 32 (3), 245-251.
Opsahl, T., Colizza, V., Panzarasa, P., Ramasco, J. J., 2008. Prominence and control: The weighted rich-club effect. Physical Review Letters 101 (168702). arXiv:0804.0417.
Opsahl, T., Panzarasa, P., 2009. Clustering in weighted networks. Social Networks 31 (2), 155-163.
1.
Seung Joon Jun | May 26, 2012 at 8:36 am
Dear Tore,
You made an amazing advance in the network analysis. Thanks for sharing good stuffs.
I have been working a longitudinal network analysis using your “weighted_richclub_w()”. But, i am having consistent warnings and errors. Spending some hours on your R scripts, I found that my data could not get through your “phi ()”. I spent hours on it, but because of my short knowledge about R, I still have several lines in your codes that I could’nt understand. Could you explain a little bit more about the following two lines in your phi function? Especially, I am having a problem to get through the second line.
(1) Er <- sapply(output[, "x"], function(a) which(net[, "rc"] > a))
(2) output[, "num"] <- unlist(lapply(Er, function(a) sum(net[a,"w"])))
It would be very helpful for me if I get several words from you about this.
Thank your time, and Best
Joon.
2.
Tore Opsahl | May 29, 2012 at 5:11 pm
Hi Joon,
Thanks for using tnet!
The phi-function is the non-normalized weighted rich-club coefficient. The line starting with Er finds the ties within the prominent nodes. This should always be a list-object, so in tnet 3.1, sapply has been changed to lapply. The second line sum the tie weights of these ties.
Hope this helps,
Tore
3.
Harsh Thakkar | June 9, 2012 at 12:25 pm
Dear Tore sir,
I am very interested in SNA as my research area. I am new to it, and luckily i found this webspace :-) You have done remarkable work.
There is too much to learn as am new to it. I have a confusion as to where to start from? I am doing my Masters in Computer Science from National Institute of Technology, Surat. Could you plz help me in drawing a path?
I will keep in touch and follow your work to get in detail of this area. It would be great boost if you could guide me sir. (I know you are a busy person, still i ask you :-D) I just loved your work.
Thanks already,
Warm Regards,
Harsh
4.
Tore Opsahl | June 11, 2012 at 5:59 pm
Thanks for the comment and email, Harsh. Hope you find the email reply useful. Best, Tore
5.
Fatemeh | July 17, 2012 at 4:45 am
Hello Tore
I came across a problem in using the Betweeness_w of tnet and it would be appreciated if you please help me with that:
I am interested to use the tnet package in order to calculate Betweenness Centrality for a weighted and undirected network. My network has 1309 nodes and 4229 links. I also add the reverse relationship between nodes to get the tnet to treat my network as an undirected one.
When I run the betweenness_W in R, it only gives me the BC value for the node 1 to 1308 and the last one (node id=1309) is missing. Do you have any idea what is the reason for this?
Kind Regards,
Fatemeh
6.
Tore Opsahl | July 17, 2012 at 7:26 pm
Hi Fatemeh,
Thanks for using tnet!
There has been an update of the tnet package recently. Could you run update.packages() to ensure you have version 3.0.7? If you are experiencing similar problems, email me with the code and data you are using.
Best,
Tore
7.
Fatemeh | July 18, 2012 at 12:39 am
Hi Tore
Thanks so much for your response. I tried the recent version as well but still received the same results (the last node is missing). I emailed you the link table and the code. Could you please have a look at them?
Many thanks for your help,
Fatemeh
8.
Tore Opsahl | July 18, 2012 at 11:25 am
Hi Fatemeh,
Thank you for your email and data. This happens because node 1309 is an isolate, and is not kept when the as.tnet-function is automatically run on the edgelist (it deletes tie weights of 0). If you would like to have an isolate included, please put it into the middle of the edge id sequence. This process is shown here: http://toreopsahl.com/2010/03/20/closeness-centrality-in-networks-with-disconnected-components/
Hope this helps,
Tore
9.
Fatemeh | July 20, 2012 at 1:21 am
Hi Tore
Yes, you’re right. That node id was an isolate and so the BC value should be 0.0.
Thanks so much for your helpful advice. I could not have come up with this myself.
Best Regards,
Fatemeh
10.
Majom | July 31, 2012 at 8:35 am
Hi Tore,
thanks for your efforts.
Do you have any hints for analyzing weighted directed networks in R?
Best,
Majom
11.
Tore Opsahl | July 31, 2012 at 8:40 pm
Hi Majom,
Thanks for your comment. I don’t know of other packages specifically for weighted and directed networks. However, all but one function in tnet works on directed and weighted networks (the local clustering coefficient is not defined for directed networks; hence, only implemented for undirected ones).
Best,
Tore