Drodzy czytelnicy, blog “Brokering Closure” wyprowadza się z wordpress.com pod nowy adres: http://bc.bojanorama.pl. Zaktualizujcie swoje linki/zakładki.

Filed under: game theory, geek, networks, po polsku, R, social science, statistics, Uncategorized, web ]]>

Meanwhile, I’m working on new version of “intergraph”, scheduled to be ver. 1.3, which will rely on new version 0.6 of “igraph”.

I am sorry for the mess.

Filed under: networks, R Tagged: igraph, intergraph ]]>

These changes affect the package “intergraph“.

A new version of “intergraph” (ver 1.3) is being developed to be compatible with the new “igraph” 0.6. Until it is ready, there is now package “intergraph” version 1.2 available on CRAN, which still uses the old 0-convention. It relies on legacy version of “igraph” (version 0.5, now called “igraph0” on CRAN).

To sum up:

- If you have code that still uses the old version of “igraph” (earlier than 0.6) you should load package “igraph0” instead of “igraph”, and use package “intergraph” version 1.2.
- If you already started using the new version of “igraph” (0.6 or later), unfortunately you have to wait until a new version of “intergraph” (1.3) is released.

As I wrote in the next post, in the end there is no package “intergraph0”, just the new version 1.2. Consequently, I have edited the description above.

Filed under: networks, R Tagged: igraph, intergraph ]]>

It’s been a while since I wrote something, not without a reason. Last months were terribly busy for me. First of all, I defended my PhD (yay!). Second, a lot of my time was consumed by writing proposals. Third, upcoming changes to R package ‘igraph‘ caused an unscheduled but necessary review of some of my R packages. Nevertheless, I should be able get back to more regular blogging from now on.

For now three links from May:

- Wired now features a new blog (first post on January 7, 2012) devoted to social sciences called Social Dimension written by Samuel Arbesman. Recent interesting posts include:
- On mathematical/statistical methods of studying coincidences refreshing Diaconis & Mosteller (1989) paper. Coincidences can be quite numerous e.g.: if something happens to one person in a million then it should happen around 250 times a day and roughly 100 000 times a year.
- Epidemic-like dynamics of donations after tsunami in 2004.

- David Smith (Revolution Analytics) writes about recent EU High Court ruling in a case of SAS vs WPS. SAS is a data analytic software developed by SAS Institute and WPS is a low-cost clone of SAS capable of processing SAS data files and selected types of SAS scripts. The High Court ruled that “the programming languages cannot be copyrighted”. Here is the official press release.
- The Promising Future for Mathematical Sociology at ASA Math Sociology blog Permutations.

Filed under: social science, web Tagged: links ]]>

Today in the morning I gave the workshop “Introduction to Social Network Analysis with R”. Over 50 people registered. I am grateful to all the participants for attendance. I hope the workshop was useful to you, despite some of the technical difficulties in the beginning!

Here are some pictures:

Filed under: networks, R Tagged: conference, igraph, intergraph, workshop ]]>

With the functions provided in the current version (1.1-0) you can convert network data objects between classes ‘igraph’ and ‘network’. The package supports directed and undirected networks, and handles the node, tie, and network (graph) attributes. Mutliplex networks (i.e., with possibly multiple ties per dyad) are also supported, although not thoroughly tested.

Network objects of class ‘network’ (from package “network”) can be used to store hypergraphs. Conversion of these is **not supported** at this time.

Both ‘igraph’ and ‘network’ classes can be used to explicitly deal with bipartite networks. Currently, for the bipartite networks, only the conversion from ‘igraph’ to ‘network’ will work. I hope to be able to add the conversion in the other direction in future releases.

You can download and install the package from CRAN. The package sources are hosted on R-Forge here.

Filed under: networks, R Tagged: intergraph ]]>

I was wondering if anyone knew of a script or tool which would give me the network distance of nodes to a particular class of nodes. I think of this as an Erdos number, except instead of getting the distance to one node, I want the distance to the closest node of a particular class. Let’s say I have a network of people and I know their professions. Some are Students, some are Journalists and a small number are Engineers. I’d like to be able to find out the network distance of each node to the closest Engineer node. It would be particularly useful if the script also had the option to total edge weight into the calculation.

If you get your network data into R it is fairly straightforward to do this using igraph package. Here is the function:

# shortest paths to nodes with a specified value on certain node attribute spnt <- function(g, aname, avalue, weights=NULL, ...) { require(igraph) stopifnot(inherits(g, "igraph")) a <- get.vertex.attribute(g, aname) m <- shortest.paths(g, v=V(g)[a==avalue], weights=weights, ...) apply(m, 2, min) }

It assumes that ‘g’ is a network (object of class ‘igraph’), ‘aname’ is a name of the node attribute, ‘avalue’ is the value of the attribute ‘aname’ that designates the nodes to/from which we would like to calculate distances, finally ‘weights’ can be optionally used to include weights in the calculation (as a numeric vector).

The function will return a vector of distances in ‘g’ from all the nodes to the closest node that have a value ‘avalue’ on attribute ‘aname’.

As an example consider the network below. It is undirected and has 15 nodes. It has two attributes defined: a node attribute called “color” having values “orange”, “lightblue”, and “lightgreen”, and an edge attribute called “w” with values 1 or 2. Both attributes are shown in the picture as a node color and edge label. The numbers on the nodes are node ids.

Assuming that the network is called ‘g’ we can use the function above in the following way:

> # from lightblue nodes to all others > spnt(g, "color", "lightblue") [1] 0 1 2 1 2 3 0 1 2 1 2 3 2 3 4 > # from orange nodes to all others > spnt(g, "color", "orange") [1] 1 0 1 0 1 0 1 0 0 2 1 0 2 1 0 > # to lightblue, but using weights (shortest path = minimal weight) > spnt(g, "color", "lightblue", weights=E(g)$w) [1] 0 2 3 1 2 3 0 2 4 2 3 4 3 5 5

A couple of end notes:

- In the result vector you will get 0s for the nodes of specified type, i.e. in the last example there are 0s for the “lightblue” nodes.
- If a certain node is not connected (directly or via other nodes) to any node of specified type the vector will contain ‘Inf’ (plus infinity).
- The algorithm will not accept negative weights. But this limitation can be effectively dodged by transforming the weights so that they are all positive (for example adding some number), performing the computation, and then transforming back the results to the original scale.
- You can exploit other features of ‘shortest.paths’ function, on which this function is based. Any extra arguments to ‘spnt’ are passed to ‘shortest.paths’. For example, if the network is directed you can calculate shortest paths that are either incoming, or outgoing (via ‘mode’ argument). See help page of ‘shortest.paths’.

Filed under: networks, R Tagged: igraph, shortest paths, socnet ]]>

Meanwhile, the paper by Lyons, which was available through ArXiv repository since July last year, got published in *Statistics, Politics, and Policy* journal here (thanks to Ilan Talmud for noticing that). All the substantial points remained largely unchanged as compared to the ArXiv paper. However, the author supplemented the paper with a truly hair-raising account of the struggle he had to go through to publish the paper: rejections from several journals without reviews or even reasonable explanations. I definitely recommend reading it.

Using the occasion, I also recommend two other papers related to this “debate”:

The first one is a response of Christakis & Fowler to some other critical comments on related issues:

Fowler, James H. and Nicholas A. Christakis. 2008b. “Estimating peer effects on health in social networks: A response to Cohen-Cole and Fletcher and Trogdon, Nonnemaker, and Pais.” *Journal of Health Eco**nomics* 27:1400–1405.

The second one is by Hans Noel and Brendan Nyhan

“*The “Unfriending” Problem The Consequences of Homophily in Friendship **Retention for Causal Estimates of Social Influence*” (download)

in which they use MCMC simulations to show, in short, how network homophily could have confounded the purported contagion effects reported in the studies by CF.

Filed under: networks Tagged: homophily, review, simulation, social influence ]]>

Apart from the cooperation topic per se what I find especially interesting is that the text convincingly shows the great merits and excitement of doing interdisciplinary research (in this case on the boundaries of social sciences, biology and artificial intelligence). Moreover, the strengths of mathematical modeling in the social sciences.

It was also funny for me to learn that prior to organizing the iterated PD tournament Axelrod asked some famous people to play the iPD against the computer. One of those persons was James Coleman. He is reported to have said that “I am doing better than computer, so I guess I’m doing fine”…

The text: Launching “The Evolution of Cooperation”.

Filed under: game theory, social science Tagged: cooperation, theory, tournament ]]>

If you think that R is The EnvironmentForStatisticalAnalysisAndGraphics but you **do not** think that Vim is The Editor for text files you might want to have a look at R Studio. It works on Windows, MacOS and Linux. I tried it out on my Ubuntu and it looks and works brilliantly. See more screenshots here. I will seriously consider it for teaching R.

My fingers are already addicted to Vim, so I do not plan to switch to any alternative interface any time soon.

Filed under: geek, R Tagged: gui, ide, interface, linux, mac, windows ]]>