Showing posts with label info-to-knowledge. Show all posts
Showing posts with label info-to-knowledge. Show all posts

2016-01-08

Age of U.S. President Candidates




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.

2015-06-08

So what can you do with data?

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…

  • Tell Stories: This is what marketers and journalists do. It is about visualisation and pervasive analytics.
  • Find Insights: This is what business analysts do. They spot interesting phenomen. I like this kind of data business most.
  • Create Products From Data: This is what product managers do. They care about rights to privacy (or how to circumvent it), unique selling points, pricing and so on.
  • Collect, Clean, Merge, Mine Data: This is what field researchers and DBAs do. Semantic structures like ontologies and vocabularies become more and more important, especially when it comes to integration from different data sources.

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.

2015-05-21

Smart Data Kick-off Conference

On April, 22nd, a kick-off conference for the German innovation program “Smart data” took place. I took part, here is what I learned.

Prescriptive Models

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.

Data as Business Case

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.

Pilot Projects

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.

Nightcrawler Movie

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.

Highlights of Re:publica 15

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.

Surveillance Everywhere

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.

Privacy

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.

Innovations

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.

2015-03-08

Highlights of Re:publica 14

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):

Robot Journalism

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.

Hypertopical News

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”.

Bullshit

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.

Miscellaneous

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.

2014-03-02

Consecutive Numbers in Lottery Draws

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

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 junior data scientist

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

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

The mathematician

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

The existentialist philosopher

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.

2014-02-14

Auto-curated playlists at Youtube

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?

2013-09-03

Gillray on knowledge gained from books

James Gillray, L'Insurrection de l'Institut Amphibie -- The Pursuit of Knowledge (1799)

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.

200 years later it is still true

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.

  1. Draper Hill Fashionable Contrasts. Caricatures by James Gillray, Phaidon Press, 1966

2013-02-16

Some of Excel's Finance Functions in R

Last year I took a free online class on finance by Gautam Kaul. I recommend it, although there are other classes I can not compare it to. The instructor took great efforts in motivating the concepts, structuring the material, and enable critical thinking / intuition. I believe this is an advantage of video lectures over books. Textbooks often cover a broader area and are more subtle when it comes to recommendations.
One fun excercise to me was porting the classic excel functions FV, PV, NPV, PMT and IRR to R. Partly I used the PHP class by Enrique Garcia M. You can find the R code at pastebin. By looking at the source code, you will understand how sensitive IRR to its start value is:
> 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.
The class did of course not only cover the time value of money, it was also a non-rigorous introduction to bonds and perpetuities (which I found interesting, too), as well as to CAPM and portfolio theory.

2013-02-14

Reflections on a Free Online Course on Quantitative Methods in Political Sciences

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.

Theoretical concepts

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”.

Modeling

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.

Didactical notes

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.

2012-06-06

Is defrosting the freezer worth the trouble?

Short answer: No, not in my case.

Long answer: My refridgerator is about 5 years old, has a volume of 103 liters and a freezing compartment of 16 liters. Its energy class is “A”, the label states a power consumption of 219 kWh per year.

I borrowed a power meter, and measured consumption before and after defrosting. Here is a chart of the measured data. I measured only 5 values, one week before defrosting, 1 hour after turning the fridge on, and then 8, 23 and 47 hours after defrosting. The y-axis shows the average power consumption, i.e. the intensity the fridge sucks energy.


The data suggests that the power consumption is on average at 15.9 Watt. The difference before and after defrosting is 0.5 Watt. I do not want to attribute this to the defrosting. The outside temperature in the week before defrosting was higher, also I used the fridge more often because there were holidays and I was at home. But even if defrosting would have this effect, these 0.5 Watt add up to only 4.38 kWh or 1.50 EUR per year.

Another insight was that 15.9 Watt project to 139 kWh per year and this is quite below the value 219 kWh stated on the energy label. Even after 5 years! Maybe this is because I put the thermostat a rather low level (2 out of 5), or maybe the consumption in the summer will be much higher.

2012-02-25

Comparing my expenses

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).

2012-02-04

Berlin's children

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.

2012-01-28

Categorizing my expenses

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:

  • It is made by people who have thought more about consumption classification than I ever will.
  • It is feasible to assign bank transactions and tracked cash spendings to one of the 12 top level categories.
  • It is widely used by statistics divisions, e.g. the Federal Statistical Office of Germany, Eurostat, and the UN. This means I can do social comparisons: In which categories do I spend more money than the average? Do the prices I pay rise faster than the price indices suggest?

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.

2011-12-30

Electricity prices rose by 16% in two years

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

yearEUR-Cent/kWh
200829.8
200933.1
201034.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.

2011-12-29

How much is a shower?

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:

2011-12-28

Heating costs

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:

2011-12-12

Semi-transparent colors and EMF -- an open problem

One nice development in visualisation  -- in principle -- is the use of semi-transparent colors. You can use it to plot probability densities, overlapping histograms, surfaces, and maybe other nice things.

In practice, however, semi-transparent colors suck. Unless you are happy with PNG or PDF for monitor use only, stay away from them. That's my advise. Especially if you are stuck to the windows platform, and want to produce an "enhanced" meta file (EMF) for your word document, chances are you will break out in tears if you try semi-transparent colors.

The problem seems to be the EMF format. Here are some of my experiences of what does *not* work in this setting.

Microsoft office inherent problems
One would expect that Microsoft's office programs work flawless with its proprietary vector-graphic format EMF. But they do not.
  • You can not rely that your Powerpoint graphic with semi-transparent colors will print out properly, neither from powerpoint nor if you copy it to word first.
  • You can not save your word doc as PDF if it contains semi-transparent colors and assume the PDF will contain semi-transparent colors, too.

Problems converting PDF to EMF
Since R's emf() device does explicitly not support semi-transparent colors, one option might be to first export the graphic to PDF or SVG, and then convert it to EMF. I did not succeed on this.
  • a software called pdf reader produces something semi-transparent, but of very poor quality
  • Inkscape's and pstoedit's exported EMF displays semi-transparent color as solid colors
  • pdf2picture has not provided an answer
  • I did not find any converter from SVG to EMF

Other options
So, if your end product is not a SVG, PNG or PDF file not intended for printing, it might be better not to use semi-transparent colors. If you are visualising a probability density, try sampling or the hexbin package.

2011-07-21

Resources on Visualization

Enrico Bertini and Jorge Camoes presented their favorite resources on information visualisation. Surfing the free courses mentioned in Bertini's article,
I read about some interesting techniques I wish to learn more about (later)
  • edge bundling when visualizing graphs
  • Dorling circular cartograms named after Danny Dorling. The algorithm is described in Dorling, D. (1996) Area Cartograms: Their Use and Creation. Concepts and Techniques in Modern Geography, 59, 69 pages. Norwich: Geobooks
  • determining the optimal aspect ratio of a line graph by the shape of the graph