Blog Archives

Animating Schelling’s segregation model

April 29, 2012
By
Animating Schelling’s segregation model

Recent blog post on Animations in R inspired me to write a code that generates animations of simulation model. For this task I have chosen Schelling's segregation model.Having written the code I have found that one year ago a similar code has been...

Read more »

Generating all subsets of a set

April 20, 2012
By
Generating all subsets of a set

Recently I have calculated Banzhaf power index. I required generation of all subsets of a given set. The code given there was a bit complex and I have decided to write a simple function calculating it. As an example of its application I reproduce Figur...

Read more »

Plotting conditional densities

April 14, 2012
By
Plotting conditional densities

Recently I have read a post on Comparing all quantiles of two distributions simultaneously on R-bloggers. In the post author plots two conditional density plots on one graph. I often use such a plot to visualize conditional densities of score...

Read more »

Comparing Banzhaf and Shapley-Shubik power indices

March 22, 2012
By
Comparing Banzhaf and Shapley-Shubik power indices

Last week I analyzed Shapley-Shubik power index in R. I got several requests to write a code calculating Banzhaf power index. Here is the proposed code.Again I use data from Warsaw School of Economics rector elections (the details are in my last post)....

Read more »

Shapley-Shubik Power Index in R

March 13, 2012
By
Shapley-Shubik Power Index in R

This spring we have Rector Elections at Warsaw School of Economics. One of my collegues Tomasz Szapiro agreed to start in the elections. This induced me to write Shapley-Shubik Power Index calculation snippet in R.Rector elections in Warsaw School...

Read more »

Parallelizing Voting simulation

March 1, 2012
By
Parallelizing Voting simulation

Last week I have compared synchronous and asynchronous implementation of NetLogo Voting model. An interesting afterthought is that synchronous model implementation can be easily made much faster using vectorization.The two versions of the Voting synchr...

Read more »

Synchronous vs. asynchronous agent activation example

February 24, 2012
By
Synchronous vs. asynchronous agent activation example

This time I have implemented NetLogo Voting model to verify how agent activation scheme influences the results.The code executing the simulation is given below. It simulates two types of voter preferences encoded as 1 and -1. In this way...

Read more »

Generating directed Watts-Strogatz network

February 11, 2012
By
Generating directed Watts-Strogatz network

There are two limitations of Watts-Strogatz network generator in igraph package: (1) it works only for undirected graphs and (2) rewiring algorithm can produce loops or multiple edges.You can use simplify function of such a graph, but then number of ed...

Read more »

Implementing Circles example

February 4, 2012
By
Implementing Circles example

This week I reimplemented part of Conic Sections 1 model from NetLogo. In the model turtles seek to to be in target distance from center.My code takes only one center point, so only circles can be obtained. Apart from turtle location plot giv...

Read more »

Replicating NetLogo Fire model

January 27, 2012
By
Replicating NetLogo Fire model

While preparing for the new semester I have started reimplementing standard NetLogo examples in R. The first is Fire model.The simulation in R is presented here:# Forest matrix trees encoding:# 3 – green, 2 – burning, 1 – burnt, 0 – no treesimu...

Read more »