This is a remake of a chart at reddit 6 months ago. I had an idea back then, but did not work it out and now the discussion is closed.
The data comes from wikipedia, dimdat and NYT.
The graph was created with R, here is the source code.
A long while ago, I took notes from an interesting presentation or blog entry or podcast. I am unable to find the source. Here I digitalize the notes: What are the main businesses you can do with data? You can…
I like this classification. Of course there are overlaps. And of course it is wrong and incomplete. Yet it is simple and thought-provoking.
As a closing sidenote, I also liked Kim Stedman's 5min talk on what data science is.
On April, 22nd, a kick-off conference for the German innovation program “Smart data” took place. I took part, here is what I learned.
One speaker differenciated between explanatory models, predictive models, and prescriptive models. The last class of models makes very much sense to me. We are going to build more sophisticated controls in our devices, and this are prescriptive models.
Regarding the data source, the common ground is to use inhouse data. Smarter projects use data from similar sources outside the firm, and/or integrate data from various sources.
Conforming to law, that is, respecting privacy and copyright, is one challenge. Another one is the automatic integration of heterogenous data source. In some pilot projects presented at the conference use semantic models for integration.
From the programs that got funded by the BMWi, there were three programs that got my attention. SmartEnergyHub analyses energy use at the airport Stuttgart and introduces load management. SmartRegionalStrategy offers strategic analysis of local urban mass data. KDI (clinical data intelligence) develops a business model for its research database / study management system.
If Baudelaire would stroll through the cities today, and look into the faces of the people he passes, what would he write down? Motivational mantras repeated by “self-optimizing” persons? A mouth of which you can not tell if it smiles or is tortured? The slight fear combined with the feeling of safety when you watch crime news in your neighbourhood? Would he make fun of the prevalence of market value theory, applied even on human life and relationships? Would he celebrate if the adrenaline sensation when your own creation goes public, or when you cross the line of the law?
If Hopper wanted to paint a urban scene today, depicting what the society is making of us, what would that painting show? Empty billboards? Dancing air men in front of a shopping market? News men in front of cardboard mache? Would he discover the aesthetics of blood and fear as, for instance, Yang Shaobin does?
I believe Baudelaire and Hopper would be in the film business today and would do a film like Dan Gilroy's “Nightcrawler”. The movie has striking representations of loneliness, both as beautiful still images as well as fine gestures of the main characters, especially Louis Bloom.
The music is not in the foreground, at one point it produced a sacral moment. Some of the music is on youtube: City of angels (Feat. C Plus), Patrona de los reclusos, Doubt me, La marcha de zacatecas, and Estrellita.
Few weeks ago, the re:publica 2015 internet culture conference took place here in Berlin. Almost 200 of the talks are available on youtube. I watched several hours of this, here is what I learned from it.
Former UK intelligence officer and whistleblower Annie Machon held a eye-opening talk on past and current activities and strategies of the intelligence agencies in several countries. Some intelligence agencies do kill people without giving them the chance to go to court. This is a big threat to the democratic state of law. See also Noam Chomsky's analysis (who was not at the re:publica).
M. C. McGrath from the Transparency Toolkit gave a great talk on what we can find out about secret surveillance programs in our country using open data and free software. He mentions that his organisation has about 27.000 profiles which may likely be connected with surveillance.
Addie Wagenknecht and Jillian York presents some artistic approaches to the surveillance topic in the post-Snowden age.
Consultant Gemma Galdon Clavell gave several interesting examples how projects can fail if possible privacy issues are not adressed earlier and properly. For instance, the netherlands had to implement an opt-out option for energy smart-metering because a story like Anne Frank hidden in a house would not be possible in a smart-metered world.
Wolfie Christl showed in his talk that it may well be possible to predict Big 5 character traits from smartphone metadata or from facebook likes. His talk led me to a browser plugin Disconnect, which allows me to control ad-tracking and social media requests online.
In order to effectively protect privacy, Frank Rieger argues that it is better to regulate how data is used than to regulate how data is collected.
Frederike Kaltheuner and Kave Salamatian point out that Asimov's fictional science called “Psychohistory” lays ground under what circumstances predictions from social media data can work. I added his “Foundation” series to my mental reading list.
My favorite talk was Stephan Porombka's on cuteness (in German). “Cute” in his analysis means something small with no obligations but at the same time heartily. He refers to Adorno's lectures and Walser's letters. I like his talk because his point of view is outside the ubiquitous technical-economical rational perspectives usually applied to explain what goes on in our digital age.
Thomas Andrae from 3M highlights upcoming applications of wearables. He points out that Google glasses – providing context to machines to maintenance teams for example – are a big success in industrial area. Andrae also mentions that sleep tracking software was minutes faster than other methods in predicting earthquakes.
Mostly not directly related to internet culture, Holm Friebe and Mads Pankow present interesting background stories and examples for the behavioural psychology technique called “nudging”.
For what it is worth, I made a simple collection of number of videos vs views. It seems that in 2013, the organization team decided to expand the number of presentations, doubling from about 75 to 150. The views per video hence the interest seem somewhat stable. Would be interesting to look for popular outliers in the videos.
From May 6th to 8th 2014, Berlin was the host for the re:publica 14. It is a conference on internet culture. As the years before, I did not attend it, but I watched some talks online. Half a year late, here are my highlights (mostly in German, though):
An area of data analysis that is moving in focus: automated text generation. At the re:publica the term robot journalism was coined. In this setting, data analysis is used to identify and interpret information worth mentioning (some kind of outlier detection?). This information is then automatically redacted into output text or output multimedia, using grammatical rules, orthographical rules, and phrase databases.
Some actors in the field mentioned in the talk are NarrativeScience, automated insights, AX Semantic Technologies, and texton.
Lara Setrakian talked about her News site Syria Deeply. She sees a positive future for single subject news sites (“xx watch”, “xx bureau”), on global issues. The content of her sites is licensed as creative commons and she plans “Teach Syria Deeply”.
When it comes to financing, she recommends not to monetize traffic/content such as ad revenue or paywalls/subscriptions, but to monetize engagements/community such as live events, conference calls, merchandizing, crowd funding, markets and job boards.
In case of Syria Deeply, financing was provided through think tanks, institutions and universities who “loved the design” and paid for technology consulting. Setrakian states: “People who know it best, often don't have a platform”.
Quite a few talks circled around bullshit. Torsten Kleinz talked on bullshit as business model. Martin Giesler and Jannis Kucharz proposed 15 journalistic startup ideas based on clickbaiting.
Christiane Frohmann from Katersalon proclaims nonsense as means for performative enlightenment.
There was a talk about the Internet Archive, where I learned that you can proactively enforce the archiving process via the “Save Page now” feature. You go to the Internet Archive's site and capture a web page for use as a trusted citation in the future. The link will not die then.
What are the baby seals, what is the police dog attacking uninvolved afro-americans, in the area of internet policy, is asked in this somewhat funny talk by Felix Schwenzel. Other theses were: Intelligence service hide their work because they do not want expose their dilettantism. Surveillance is inherent in the system, given by the technology, such as road kills are a consequence of the automobile technology.
A historian, a data scientist, a programmer, a mathematician, and a philosopher discuss the question, how likely it is that a lottery draw (6 out of 49) contains two consecutive numbers.
The historian argues that from 1955 up to 2011, there were 5026 lottery draws in Germany, every Saturday, and from 2000 on, two draws every Wednesday. In 2557 cases, there were consecutive numbers among the drawn numbers. Hence, the likelihood is around 2557/5026=51%.
By the way, he adds, did you know how Casanova got rich while he introduced the lottery in Paris?
The data scientist argues that a lottery draw is a repeatable experiment that can be easily simulated. He fires up his R console and creates first a function that checks if a draw contains consecutive numbers:
> has.consecutives <- function(draw) any(diff(sort(draw))==1)
The function first sorts the numbers drawn, and then calculates the differences between those numbers. If there are consecutive numbers, then there must be a 1 in these differences.
Now one lottery draw can be simulated with sample.int(49,6). To get an estimate for the probability of the occurrence of consecutive numbers, he repeats these lottery draws very often:
> N <- 100000
> counts <- replicate(N, has.consecutives(sample.int(49,6)))
> sum(counts)/N
[1] 0.49498
The simulation suggests the probability is slightly smaller than 0.5. To rule out this result was produced by chance, he calculates a confidence interval for the wanted proportion. There is – and that is charming about the statistical computing environment R – a package for that, which implements several methods for this task:
> library(binom)
> with(
binom.confint(
sum(counts), N,
method="wilson"),
c(lower, upper)
)
[1] 0.4918814 0.4980790
Now the theory states that if the simulation is repeated very often, in 95% of the cases the true parameter lies in the calculated intervals. Hence the data scientist is quite certain about the first two digits of the probability.
The programmer takes a recursive approach. If we find a function f(n,m) that returns the number of ways to choose m out of n numbers without consecutive numbers, then we can calculate the wanted probability by
> 1 - f(49,6)/choose(49,6)
Some corner cases for f are obvious: if m is 1, there are n ways. For n=3 and m=2, there is exactly one way. By the pigeonhole principle, when m>ceiling(n/2), there is no way.
In the general f(n,m) case, we can distinguish between the ways where neither the first nor the last number is chosen (f(n-2,m)) and the ways where either the first and/or the last element is chosen. In the latter case, by the inclusion/exclusion principle, the number of ways is 2*f(n-2, m-1) - f(n-4, m-2). In case m=2, the latter term becomes 1; this is another hard-coded return value f(n,0)=1. Altogether, the function is defined as
> f <- function(n,m) {
if(m==0) return(1)
if(m==1) return(n)
if(n==3 && m==2) return(1)
# pigeonhole principle
if(m>ceiling(n/2)) return(0)
# inclusion/exclusion principle
return(
f(n-2,m)
+ 2*f(n-2, m-1)
- f(n-4, m-2)
)
}
> 1 - f(49,6)/choose(49,6)
[1] 0.4951984
After some thinking, the mathematician comes up with equivalent problem formulation. Instead of counting the number the draws without consecutive numbers, what if we count the number of ways to draw the blanks immediately after the drawn numbers?
Given a draw N1, ..., N6 without consecutive numbers, the numbers N1+1, ..., N6+1 after each drawn number are not drawn. We have to allow the number 50 to make this work, though.
Hence, the number of draws 6 out of 49 without consecutives corresponds to number of 6 blanks drawn from (50-6) numbers. So the solution boils down to
> 1 - choose(50-6, 6)/choose(49,6)
[1] 0.4951984
Finally, the philosopher points out that it is not the result, but the solution approaches that are important. The objective truth about consecutive numbers in lottery draws is a fact. Now that it is known, it might be tempting to disregard the ways used to find it. But there is value in subjective reflection, in appreciating the individual thoughts and approaches, as this reflection deepens the understanding of reality.
Since April 2013 Youtube has a feature “Youtube-Mix”. From what I could find out searching the web, these lists are auto-generated based on the video you are currently watching.
For instance, when I watch Soha's song “Mil pasos” I get this playlist suggestion. Or, if I start from RAHJ's “15 minutes”, then this playlist comes up. Or, if I start from Holly Golightly's Virtually Happy, I end up at this playlist.
I like them very much. I wonder how these lists are generated. Since this is Google, I suppose there is some smart algorithm at work, not hand-crafted lists. But which features does this algorithm use?

Have a look at the figure above. In the image we see an experiment that goes terribly wrong. Two persons want to transfer their knowledge on horses and try to domesticate crocodiles. We see a whip, a bridle, a saddle and an instruction manual “education for crocodiles”. But crocodiles are not horses, they bite back, and turn the scene into a blood bath.
Gillray created this caricature in 1799, and it was a comment on politics. It relates to personal letters from enraged French officers in Bonaparte's Egyptian command [1]. It is the trait of a caricature to exaggerate its subject and should of course be interpreted metaphorically. The crocodiles may represent the Egypt people Bonaparte tried to subordinate as he did in many Europian countries. On the other hand, the exaggeration, which is also an abstraction, allows us to take the image out of its context and apply it to other situations. Here come two examples.
My first encounter with this image was at an exhibition on the “Age of Reason”. The topic of that exhibition was the time of the transition from religion to science that took place at the end of the 18th century: The first anatomy atlas of the inside of the human body appeared, the earthquake of Lissabon shattered faith in god, and it was the time of the French revolution. In this context, Gillray's caricature appears as a critic of the new stream of thought at that time. Maybe the people overused the scientific method in the first enthusiasm, and rather than seeing the object openly and attentively with some kind of wonder, the persons in the picture simply apply the knowledge they read in books. This goes wrong, and maybe this overacting, this trying-too-hard, is why the age of reason entered eventually the age of Romanticism, which prized intuition, emotion and imagination over the scientific rationalism.
Today, some people are very enthusiastic about data. They proclaim the age of dataism: cheap storage and lots of mobile sensors everywhere lead to huge amounts of data and many new insights. However, Gillray's caricature can serve as a warning here. Some problems will not be tamed and utilized with the right dataset and some analysis method, but will bite back.
> source("http://pastebin.com/raw.php?i=q7tyiEmM")
> irr(c(-100, 230, -132), start=0.14)
[1] 0.09999995
> irr(c(-100, 230, -132), start=0.16)
[1] 0.1999999
I still do not understand the sign of the return values. This I have to figure out every time I use the function. If you have a memory hook for this, please leave a comment.Last year I watched some videos of Gary King's lectures on Advanced Quantitative Research Methodology (GOV 2001). The course teaches ongoing political scientists how to develop new approaches to research methods, data analysis, and statistical theory. The course material (videos and slides) seems to be still online, a subsequent course apparently has started end of January 2013.
I only watched some videos and did not work through the assignments. Nevertheless I learned a lot, and I am writing this post to reduce my pile of loose leafs (new year's resolution) and summarize the take-aways.
In one of the first lessons, the goals of empirical research are stepwise partitioned until the concept of counterfactual inference appears, a new term for me. It denotes “using facts you know to learn facts you cannot know, because they do not (yet) exist” and can further differentiated into prediction, what-if analysis, and causal inference. I liked the stepwise approximation) to the concept: summarize vs. inference, descriptive inference vs. counterfactual inference.
In the course was presented a likelihood theory of inference. New to me was the likelihood axiom which states that a likelihood function L(t',y) must be proportional to the probability of the data given the hypothetical parameter and the “model world”. Proportional means here a constant that only depends on the data y, i.e. L(t',y) = k(y) P(y|t'). Likelihood is a relative measure of uncertainty, relative to the data set y. Comparisons of values of the likelihood function across data sets is meaningless. The data affects inferences only through the likelihood function.
In contrast to likelihood inference, Bayesian inference models a posterior distribution P(t'|y) which incorporates prior information P(t'), i.e. P(t'|y) = P(t') P(y|t')/P(y). To me, it seems the likelihood theory of inference is more straightforward as it is not necessary to treat prior information P(t'). I have heard that there discussions between “frequentists” and “Bayesians”, but it was new to me to hear from a third group “Likelihoodists”.
At the beginning of the course, some model specifications with “systematic” and “stochastic” components were introduced. I like this notation, it makes very clear what goes on and where the uncertainty is.
An motivation was given of the negative binomial distribution as a compounding distribution of the Poisson and the Gamma distribution (aka Gamma mixture). The negative binomial distribution can be viewed as a Poisson distribution where the Poisson parameter is itself a random variable, distributed according to a Gamma distribution. With g(y|\lambda) as density of the Poisson distribution and h(\lambda|\phi, \sigma^2) as density of the Gamma distribution, the negative binomial distribution f arises after collapsing their joint distribution: f(y|\phi, \sigma^2) = \int_0^+\infty g(y|\lambda) h(\lambda|\phi, \sigma^2) d\lambda
There were many other modeling topics, including missing value imputation and matching as a technique for causal inference. I did not look into it, maybe later/someday.
The assignments did move very fast to simulation techniques. I did not work through them, but got interested in the subject and will work some chapters of Ripley's “Stochastic Simulation” book, when time permits.
I was really impressed by the efforts Mr. King and his teaching assistants took to teach their material. Students taking the (non-free) full course prepare replication papers. The assignments involve programming. In the lectures quizzes are shown, the students vote using facebook and the result is presented two minutes later. The professor interrupted his talk once per lecture and said “Here is the question; discuss this with your neighbour for five minutes”. Very good idea.
Now that I have collected my expenditures via Twitter and bank transaction data, and categorized it according to COICOP, in this blog post I compare it with the typical expenditures of a household of my type with an income level like mine.
The German Federal Statistical Office conducts every five years (last time in 2008) a survey on Income and Consumption. On their website, you can find this nice visualization.
The dataset I used is provided here. It is also part of the pft package. The dataset is not identical with the official data, some information is lost by the processing.
Here is the chart comparing my expenses in 2011 with the typical expenses.
The main problem when comparing me with a typical consumer is that 15% of my expenses remained uncategorized. If I assume it goes in either Food, Recreation, Restaurants or Misc, and add those amounts, it turns that almost the half of my expenses goes in these four categories, while typical would be 35%. Especially I tend to spend more money on Recreation and Restaurants. On the other side, I spend less money on Housing (small apartement) and Transportation (no car).
Few years ago, a newspaper claimed the block I live in — Prenzlauer Berg in Berlin — is the most fertile region in Europe. It was a hoax, as this (German) newspaper article points out. (The article has become quite famous because it coined the term Bionade Biedermeier to describe the life style in this area.)
However, there are more children in my district than in the other parts of Berlin. Have a look at this map:
(The base map and population data come from the State’s statistical office. Data at block level is not readily available, though.)
The place I live is marked by a hair cross. Indeed, in this district there is a “higher exposure to kids” than in the other districts, one children per 1000 inhabitants more than in Friedrichshain-Kreuzberg, and twelve children per 1000 more than in Charlottenburg-Wilmersdorf. Exposure is of course different from fertility, maybe that is what I learned from playing with the map.
If you want to know how to draw this thematic map with R, and add the point and the legends to it, or if you are just looking for a shapefile of Berlin, then read on.
In order to analyse my expenses, a classification scheme is necessary. I need to identify categories that are meaningful to me. I decided to go with the “Classification of Individual Consumption by Purpose” (COICOP), for three reasons:
So I classified my last year’s expense data according to COICOP. Here is a chart showing the portions of the categories for each month:
For me, the holidays, prepared in August and traveled in September (shown as unknown expenses), are much more dominant than I expected. Except for the new glasses in September I did not make any larger investments.
I like this kind of chart more than stacked bar charts because the history for each category is very visible. This chart is called inkblot chart. I stumbled on it on junk charts, asked how to implement it in R on StackOverflow, and included a revised version in the latest pft package. See below for more information.
With about 490 kWh electricity consumption I am a rather small customer. Over the year this sums up to about 160 EUR. So I had a look at the costs.
I was suprised to learn that the prices rose quite clearly. My tariff is two-part, a base price and a kilowatt-hour rate. If I look at the total costs and divide them by my consumption, I get
| year | EUR-Cent/kWh |
|---|---|
| 2008 | 29.8 |
| 2009 | 33.1 |
| 2010 | 34.6 |
This means, in 2010 I had to pay 4% more than in 2009 and 16% more than in 2008. My energy use per day, on the other side, remained quite stable at 1.35 kWh/day.
What can I do about it? The first impulse was to collect more data, maybe by using a WiFi energy sensor. Would be really fun. However, I can not see many options to reduce my consumption. Maybe I can turn off the internet router while at work.
It seems more sensible to me to switch my energy provider, which I did today. My new energy provider will charge a bit more, but gives me 50 EUR new-customer bonus and claims to deliver certified renewable energy.
After looking at my heating expenses, I turned to the costs for water heating. For some time, I looked at my water meter before and after taking a shower or a bath. Quite often, I forgot one or the other measurement, but I collected about 40 observations. Here is what they look like:
The data suggest that for a shower, it takes between 17 and 26.5 liters hot water and between 11 and 16.5 liters cold water. For a bath, it is 60 to 77 liters hot water and 24 to 32.5 liters cold water. (The numbers refer to the 25% and 75% percentiles, respectively.) The larger share of cold water for a shower makes sense, since I use cold water at the end of the shower for its “invigorating effect”.
Multiplied with the average costs, as charged by my landlord the last three years, a bath takes 0.94 to 1.22 EUR and a shower costs 0.29 to 0.45 EUR (again, first and third quartiles). So taking a shower for 0.50 EUR at the fitness club is not optimal, but also not very expensive.
There are water saving shower heads for 30 EUR. It is advertised that such a shower head uses 6.5 liter per minute instead the usual 15 to 16 liters per minute. I believe 15 liters per minute is too much. So let’s assume I save 3.5 liters per minute or (using the median water use of the data) 12 liters per shower. Is it cost-efficient?
Twelve liters less per shower at 10.5 EUR/cbm means a saving of 0.126 EUR per shower. I assume 20 showers a month. This is tentative, since with this assumption the costs sum up to 70 EUR a year for hot water while my bills amount in average to 110 EUR total costs for hot water. So the new shower head saves 20*0.126=2.52 EUR per month.
Let’s calculate the payback period. With an interest rate of 4% p.a. and 5 years expected serviceable life the monthly gain calculates to
2. 52 - 30 * 0. 04 / 12 - 30 / (5 * 12) = 1. 92
so after 30 / 1. 92 = 16 months, the investment is repaid. This seems acceptable. But just to be sure, let’s calculate the internal rate of return, too. In excel, there is a function IRR for this procedure, which is implemented in three lines in R. For convenience, the irr function is stored in the pft package. The result is 8.3% which seems decent.
Just for reference, here comes the R code for the plot and the irr function:
In 2010, my heating costs exceeded my advance payments by about 25%. This motivated me to decompose the costs to see what drove the changes. Here is the result:
The numbers refer to Euros. Read von right to left: 2010 was a cold year (+102EUR), but gas consumption in this house was relatively low (–89EUR). Also, running costs and gas price were below previous year’s value (–49EUR). The main driver (+183EUR) for the increased costs was my share on the total costs. In 2009, I had to pay 1.7% of the total costs, which rose to 2.3% in 2010. This means my landlord assumes I used more energy than the other tennants in 2010. I doubt that, and one aspect to support my doubts is that the values of the two heat meters in my living room were nearly at the same value, while I used only one heater.
Thus I believe it was a measurement error. I am not going to complain about this, but will check next measurements very carefully.
Not a direct result of the decomposition, but also interesting is the (temperature adjusted) enery use per square meter, which was in 2010 by about 110 kWh/m2, which is nearly average.
Here’s the R code to produce the chart: