Tag-Archive for » R «

Thursday, April 05th, 2012 | Author:

The Valaisan mobility network

Methods and tools

After a day and a half of work and fine-tuning, here we go: the commuting network of all individuals either residing, working or studying in the canton Valais. I’ve used R, with the RStudio GUI, and the igraph library for R. My staring point was the mobility matrix between all communes, including communes outside of the canton, which I’ve calculated from the individual data of the Swiss Federal Census 2000.

I’ve converted my commuting matrix into a directional weighted graph with the graph.adjacency function. I’ve simplified the graph by removing loops.

The vertex size has been determined by betweenness. To reduce size difference, I’ve squared it.

The graphic layout has been obtained with Fruchterman-Reingold algorithm, included in the igraph library.

To determine communities – identified by 11 different colors in the map above – I’ve tried out edge betwenness, leading eigenvector and finally settled for the walktrap community, which gave the most interesting results. Walktrap community, however, remains non-directional. I am still looking for a directional weighted algorithm appropriate for my study case.

The width of the edges depends on the original weights. In other words, thick lines identify paths taken by most individuals.

Some interpretations

As often when reconstructing a network space from a geographical commuting matrix, the resulting space reproduces very closely the topology of the topographic layout of the canton. This is especially understandable in the case of Valais, because of its West to East tree-like structure.

A clear boundary appears between the French-speaking (Monthey, Martigny, Sion, Sierre, Montana) and the German-speaking (Brig-Glis, Visp, Zermatt, Fiesh etc.) communes. Obviously, the linguistic communities exchange only few commuters.

Also interestingly, commuters from Geneva and Lausanne do not connect to the Monthey subnetwork (which would be the closest from these cities further West on the Lac Léman), but share community with Martigny. My earlier unweighted tests with the walktrap algorithm even attached them to Sion. This confirms the hypothesis that larger cities preferentially “interact” with other urban centers, in terms of all types of geographical interaction (commuting, information, financial flows etc.). Smaller cities, like Vevey, Aigle or Montreux, on the other hand, participate preferentially to the Monthey commuting community. Besides their small size, their topographic closeness to the Valais also leads to this.

References

Pons Pascal, Latapy Matthieu (2005), “Computing communities in large networks using random walks” in arXiv:physics/0512106v1 [physics.soc-ph].

Tuesday, June 14th, 2011 | Author:

RStudio logoR is the greatest open source statiscal programming package around. It is all a mapper need to pretreat data. Yet it suffers from interfaces that are either uggly, tedious to set up, clumsy to use or all of these. After years of glaring at the Windows interface of R, I’ve finally sutmbled upon a nice tool which takes seconds to intall. It’s called RStudio, it’s  available since February 28th 2011 and it displays many nice features among which:

  • Code coloring.
  • One-button execution of selected lines.
  • Code search and replace toolbar.
  • Workspace data and values listing, extremely useful to keep up to date with variables and arrays you’ve produced in lines of code. This pan lists all objects with their type and dimnesion (e.g. “b : character[2]“; “dat : 4159 obs. of 49 variables”, “ab : 2×2 double matrix” etc. )
  • A searchable help pane.
  • etc.

All of this neatly packed in one interface window, with tabs giving access to plots, files and to all the other nice things you expect R to do.

Among lacks of this Beta version, on could still mention:

  • The “import dataset” button only allows you to load comma-separated values. It would be more interesting if this button’s options allowed users to load Excel, SPSS, etc. files. For now, you can always run R Commander (> library(Rcmdr) )  and use the “Data>Import data” menu for GUI access to datasets.  Other Rcmdr menus would also be welcome in R Studio. Why not merge them?
  • No code completion in the coding pane.
  • A slightly clumsy packages manager.

In brief: RStudio is a nice piece of software to follow closely, and already of great help in ist current version.

Category: Tools  | Tags: , , ,  | Leave a Comment