Source Code

 

torfason.igraph.utils

This is set of utility functions written while working on “Organizing the In-Between”. The collection provides a number of network manipulation routines using the igraph package for R. The utilities include functions to collapse a two-mode network (say of individual memberships in groups), into a one-mode format (the network of individuals tied to other individuals through shared membership in groups). Also included are edge-aware set operators for networks (intersect/union/difference). These work on networks based on the names assigned to each node, rather than the numerical IDs of each node, allowing for substantively meaningful intersections or unions of two networks involving the same or similar set of nodes.

Example:
my.onemode.network = twomode.collapse(my.twomode.network)
both.friends.and.neighbors  = graph.intersection.by.name(
friend.network, neighbor.network)
either.friends.or.neighbors = graph.union.by.name(
friend.network, neighbor.network)

More detailed usage examples are included in an accompanying file in the download.

torfason-utils-igraph.zip

 

 

statalike

This is set of utility functions written while working on “The Global Rise of Democracy”. The collection implements a number of functions familiar to Stata users in the R statistics program. The first argument of each function is the name of the data.frame to use, followed by the relevant column names. An optional argument can be used to pass an if statement.

Example:
d = st.keep(d, reap.amount, sow.amount, land.type, rainfall)
d = st.sort(d, land.type)
model.1 = st.regress(d, reap.amount, sow.amount)
model.2 = st.regress(d, reap.amount, sow.amount, land.type, rainfall)

More detailed usage examples are included in an accompanying file in the download.

statalike.zip


If you find any of the above source code useful (or not), and in particular if you make any improvements to it, I’d love to hear about it. Please contact me through http://people.hbs.edu/mtorfason/.

Current time is available at zulutime.net