Economics, Random Thoughts

Marriage Bill and the Law of Diminishing Marginal Utility

Utility is a very interesting concept in economics. Essentially it can be used to mean preferences. We prefer some things over others. Going to shop, an individual will pick one brand of say bread over another, or a loaf of bread over cake. In economics you can say that the utility of bread is more than the utility of cake.

Now, if you have not eaten bread for some time, you will really enjoy the first bread than if you had eaten some earlier. Each time you eat bread after eating it previously you will probably enjoy the bread less and less. You can generalize this for anything you like. In economics this is called the law of diminishing marginal utility. It can be represented by the graph below.

New Picture

Red line: represents Preference

Blue Line: represents Enjoyment derived from additional Q

You will note that while you prefer more loafs of bread than few (Red Line), you enjoy more and more                                                               bread less (you might even end up throwing some)

Suppose that the cost of a loaf of bread goes up, everything else remaining constant. The most likely reaction will be to reduce spending on bread. If you were buying two loafs, you might consider buying one etc etc.

Put differently; it would be cool to have a loaf of bread if you do not have one already, if you do, then its also great to have another, but having the one already, you do not enjoy having the second one as you did while getting the first, and if, perchance, the cost of buying a loaf increases, then you are less likely to buy a second.

Looking at this concept in the light of the new law on polygamous marriages, from an economics point of view, It would be preferable for men to marry many wives, however, for each additional wife, the man enjoys less of the women; and the additional lady is slightly less valued. And if the cost of living rises, the man is likely to dispense with one of the ladies.

And there it is; my three pence thought!


How many Kenyans earn upwards of 100K per month

Once in a while you come across a tweet that you read twice, then favourite;  This was one of those

Then this came through yesterday

And it immediately hit me that maybe this could answer, once and for all, how many Kenyans earn above 100K per month. I think that the original post on this issue was not empirical, and though the assumptions they made were plausible, there figure of  “ just under 20,000” seamed somewhat assumptious to me. This post hopefully, settles this (and I can now unfavorite the tweets!)

I will make a few assumptions of my own though. First, that banks, the main financiers in mortgage financing will look at the applicant’s ability to repay the loans (bank account details). And second, the report from which the second tweet is from (i think) is reliable.

Okay, now lets start with this tweet:

Kenya has about 8 million urban dwellers. Doing the math, that means about 80,000 Kenyans can finance 5.7M mortgage. To finance that kind of mortgage, you need to put a 20% deposit and need to have a salary of at least 100,000 per month.  

There you have it, about 80,000 Kenyans may be earning 100K a month (what they actually carry home is another thing all together)

My three pence thought



Traffic filter project: road updates from twitter

Traffic in Nairobi is a big issue. Traffic jam is about Kshs 50M daily issue, and everyone wants a go at it. Disparate ways but all converging on one issue,  solving the traffic issue. Ma3Route, Twende twende, Here Maps, OverlapKe are just some of the solutions. Each approach, has its strength. And weakness.

There is no undervaluing the power of crowd-sourced information though. And here twitter wins. Apps that post to twitter like @ma3routes, @overlapKe are a great help if you need information. And more importantly, as twitter is like a dartsboard where people throw their frustration about traffic and other issues, if you listen keenly, maybe you can hear about the traffic situation on most roads. The problem comes when you have to either search through volumes of tweets (some irrelevant) to get the information you need. And with the huge numbers of #KOT and tweets about traffic this can be a real problem. Yet the abundance of tweets presents a valuable opportunity to build a filter.

I have been interested in how people tweet about traffic. I have routinely collected some 50K+ on tweets on traffic situation around Nairobi over three months period (some of the tweets can be found here). I will post the detailed analysis here sometimes in the near future. The biggest take out of this was that most people tweet about traffic situations to ask for updates, or to vent. When there is no jam, people tweet less (unless its an uncommon). Most traffic apps in Kenya today loosely satisfy these needs. The growth of these apps leaves a trail of big data which is ripe and albeit more useful for text mining and analysis.

Over the Easter weekend I decided to build a filter. My reasoning was quite simple. Build a twitter app which can be queried (via mentions) to give traffic updates about a particular road (and accidents). I was also interested in tracking cases of accidents within Nairobi roads. I decided to start this app with a road I use everyday; Thika Road

In a nutshell:

From the analysis of over 15k tweets, I created a hash table of some of the common words used to describe traffic with a scale from 1 to 10 reflecting the “badness” of the traffic situation.



Then I created a list of all bus stops (ordered) from Ruiru  to town (Ruiru = 1, KU = 2 … etc)

The logic of the algorithm behind the app works as follows:

1. Using the library(twitteR) search and extract 200 mentions of the word thika road or the list of bus stops .

2. Clean the data by removing periods, comas, #, $, and any other characters, as well as links and people mentioned and save.

3. Breakup each tweet and loop through the tokens searching for the word accident using cosine distance less than 0.15 and code these as accident

4. Search through the tokens for all the mentions of the bus stops and if it is the first mention record this as FROM, if second, TO, if only one mention record as AT.

5. Search through the tokens (cosine/jaccard distance) for the ranking of the traffic situation and code the nearest using the Pseudo column of and Linkert column in the guide traffic data frame.




6.  Get all the tweets that are coded as Accident and get the locations (AT) and the time tweeted. Tweet the accident if is has been less than 2 hours since the accident and is not similar to another reported accident (similarity in terms of location and time).

7. Get all the tweets that have traffic ranking and  tweet them if they are updates for less than 1hour ago, and have not been already reported.

Finally, the output is given at @RoadStats

I am currently working on trigger for mentions so that anyone can request for traffic update by using a hashtag and road.

Feedback and opinions; highly welcome!!!


He’s dead, Jim! … musing on Open Data in the age of peta-data

I made a startling realization today. an aha moment if you like. In a few years, the clamor for open data will die out.


Human behavior, and social economics, or at least my three pence thought on this issue, tells me as much. My reasoning is simple; we will only throw away what we no longer need (or ever will).

Over the past few years, the talk around open data, data science, big data … and all things data has grown louder. Everyone wants a piece of the action. Everyone wants to use their data to optimize processes, to make better decisions, to illuminate spending, … to be better. In advertently, what was previously trash (non-usable) is now being horded in abundant stores and servers. Suddenly, data has become that diamond in the rough. And with reactions reflective of its newly acquired status, the grip on data has tightened, and the grip is likely to grow tighter with every new spackle of the data diamond. We have collectively become compulsive hoarders

In 2012, every day 2.5 quintillion bytes of data (1 followed by 18 zeros) are created, with 90% of the world’s data created in the last two years … more

The question that arises is just how much of this data is open, or will ever be open. The reality is that almost a negligible percentage will ever be open, and even then, the data will have been hopelessly summarized and anonymized to be realistically usable. Human behavior suggests that we only throw out what we consider as garbage; what we do not hope to use; ever. And with such growth of data, the data dumps will be growing at an unprecedented rate; rates that will never be matched by the release.

Watching BBC documentaries trashopolis give a glimmer of hope. That even in the putrid mess of outdated, highly summarized, and distorted data, there will be those who will dive in and make some semblance of order, some meaning, some ideas. May be one may be able to build a beautiful island of trash data like these three amazing trash islands . May be, just may be, some George Waring(s)  will help make some order in the chaos of trash data.