Saturday, August 27, 2011

Easy way to stop smoking, this time it works!

It was Supposed to be Easy
Like millions I read the famous book by Allen Carr "Easy way to stop smoking". Like millions, I tought: he has a point. Many quited, but I went on. Now I'v found a secret weapon of mass responsibility, where I can change my behavior for good. The weapon is called Commitment Contract.

UPDATE: it's now over a month since I am without smoking. It was tough, but you just stick with it.

Why Quit?
The consequences of my behavior are well studied:
Men born in 1900-1930 who smoked only cigarettes and continued smoking died on average about 10 years younger than lifelong non-smokers. Cessation at age 60, 50, 40, or 30 years gained, respectively, about 3, 6, 9, or 10 years of life expectancy. 
 [ study prolonged over a century]


This is the current best knowledge:
  1. Quit before 40 and chances are that your smoking has no consequences. 
  2. Quit before 50 and you shorten your life for -5 years.
  3. Quit before 60 and you shorten your life for -7 years.
  4. Don't quit and you shorten your life for -10 years.
Why Smoking?
Addiction is all about dopamine, a hormone that makes you feel happy. A cigarette gives you a small dose of Nicotine which in turn kickstarts the increase of adrenaline, serotonin and dopamine. You are more aware, more reactive and more happy after smoking. Just a little, not much.
To learn what is good for one-self is crucial for the sophisticated survival machines we are. Therefore a mamals brain learns to seek dopamine rewards. With every cigarette you learn that smoking is good, and the absence of nicotine worries you. The phenomena of withdrawal.
Although the damages it does are way superior to the possible benefits, not everything is bad with smoking: current medicine knowledge is that nicotine helps against alzheimer's and parkinson's. But I also love the nicotine rich tomatoes and potatoes and I started to complete my nutrition with Omega 3 DHA and EPA (makes you smart and protects against the major civilatory deseases like Alzheimer and cardio-vascular deseases).

How to Quit?
Good news: smoking does not provide increasing dopamine returns.
For a binge drinker, every drink augments the desire of another drink.
Even for a chain smoker this is not the case. The craving for a cigarette might not disappear but it certainly does not increase.
Decreasing Returns
The first cigarette is the most wanted.
The addiction develops more as a decrease in the inteval between two smokes.

This is important. We now know the maximum craving is the longing for the first cigarette. We can measure it! What is the unit of measurement? An economist would say: money. I'd say: money is not enough, but a good start. How much would you give me for a cigarette if you really need one?

  1. Would you give me 100 Euros? 
  2. Would you give me 50 Euros? 
  3. Would you give me 10 Euros? 
  4. ...

There is an amount which you would pay when craving hard. I decided mine is somewhere around 5 to 10 Euros. This is a measure of your addiction.


Hedging against Smoking
If you want to stop smoking you have to make sure that for each cigarette you smoke, you will lose more value than your addiction treshold. For example you can  formulate a contract: "I pay 10 Euros for every cigarette I smoke." I did this, but I did more:

  1. I determined a period for the contract: until 2012-01-01 (Short! Somehow I was not ready for more)
  2. I convinced a friend to be my referee, I gave him 100 Euros to take under ward. 
  3. I declared in my contract that I have to give 10 Euros to a detestable political organisation for every cigarette I smoke. This is anti-charity. This is admitting we are not homo economicus - it is is for the social animal in us. Donating the money to an anti-charity pushes the commitment from being only a higher price (I pay for it, so I have the right to smoke it) to something that would weaken your identity if you fail.
My incentives to resist the Nicotine-crave are now bigger than the temptations.
During the first week I felt the urge to smoke strongly. Sometimes I couldn't sleep well, I was nervous. But it really never came to my mind to smoke a cigarette. Its clear that I do not want to donate to the detestable political organisation. The idea of doing that kept me away from the cigarettes. I've externalized my right to smoke by installing a penalty. If it works for the traffic police it's certainly good for keeping me away from bad habits.


The ideas presented here come from Ian Ayres' Carrots and Stick. The idea is genius but the book is a little bit boring, I'd recommend his other book "Supercrunchers".

Thursday, July 28, 2011

Which day I lose weight

I could swear it is weekend's.
But making a 'seasonal' plot, thus aggregating all data for each weekday, showed I do not so good on weekends. Especially Sundays. I am supposed to do sport on sundays. But, hey we had really bad weather the whole July. And some social obligations too...

Is it my day?
Boxes and Wiskers Plot of weekdays: the horizontal line in the middle is the  median. Upper box border is the 75% quartile, lower border the 25% quartile,so that 50% of values are between 25-75%. Lines outside are the the next 2-98 percentiles. Dots are outliers. Forget the legend, 0.8 is only the opacity of the boxes.


So in hindsight my worst day is Sunday and my best is Wednesday. How does it relate to kcal left to base rate? How would a weekday regression look like?
A weak start
The regression tells that sunday and monday are fatty
The bigger the dots, the more calories left to base rate. 

I even cheated one sunday because of overnight stay in the mountains, including booze, I didn't record.
Disclaimer: You don't know what a mountain is, if you where not there. And I know the evidence is 'thin', five data-points per weekday is not what you should base a scientific law upon

Sunday, July 24, 2011

More Quantitative Diet Analysis

Two Questions:
  1. What is the correlation between calorie consumption and weight loss?
  2. Is it happening the same day?
This Saturday, I skipped hiking up to the mountains to answer these naging questions my last diet analysis left over. To answer them, let me first present the data, carefully recorded over 35 days of dieting.

Weight-loss per day
Measured each morning before breakfast and after taking a crap, pardon my french.
How much did I lose on a regular day? 
Most of the time lost between  -0.07 and 0.5kg





The Percentiles are: 
Min.     1st Q. Median  Mean  3rd Q.  Max. 
-0.66kg  -0.07  0.16    0.2   0.5     1.5kg 

The 1.5 kg outlier draws the attention. Is it a measurement error?

Net caloric intake per day
This is the amount of calories I have eaten, minus the calories that I have burned doing sport.
When I say calories I mean the american metric which corresponds to the european kilo-calories (kcal).

Caloric Balance Sheet
How much calories did I take-in and consume in a day?
Most often 500 kcal to 960 kcal



















  



The Percentiles are: 
Min.      1st Q  Median  Mean  3rd Q  Max. 
-1009kcal 490    660     630   960    1480 kcal 

My friend, the outlier, is here again. Seems reasonable: A day of heavy exercise and little eating... but 1.5 kg? That's a lot.

Caloric intake left to cover the daily base burn rate
Now its getting nasty. Our body consumes calories even if we lay in bed all day. This is the base rate. Whitout getting into details, it depends roughly on your body weight. When you take-in lesser calories than the base-rate (plus exercising) you lose fat. My formula for this spread goes like this:
kcal_left = base-rate - net_kcal

And the distribution of the not consumed calories is:
Distribution of calories-left
I normally underperform the base-rate by 250kcal - 730kcal.




















   

   Min.   1st Q Median  Mean 3rd Q  Max. 
 -240kcal 250   520     570  730    2230kcal 

Median underperformance is 520kcal, roughly a spurned Pizza Magherita. Two times I've consumed slighty more than the base-rate. And the outlier from my sport weekend is here too!

Correlation between calories left and weight-loss
Back to question 1: What is the correlation between calorie consumption and weight loss?
Now I know that I have to maximize calories-left (to the sedentary base-rate) in order to lose weight.
What are the results of my effort?


Figuring a trend
The Linear regression line in blue 
shows there is a positive correlation
between calories-left and  weight loss.
The border of the darker region
is the mean deviation oft the data 
from the regression line,
a.k.a. the standard error.













If you are a genius you certainly have noticed that the outlier is away. It would have greatly influenced the regression and I felt that I want to answer what happened in normal days. Also the correlation is not high (R^2 = 0.3541857), there are other effects that influence the variables a lot and it's clear that grand part of them are measurement errors.

Coefficients of the regression line are:
(Intercept)   kCal_Left  
 0.1174047    0.0001555  

Basically this is the linear function:  
weightLoss = 0.1174047 +  0.0001555 * kCal_Left

For the median calorie underperformance of 520 kcal this means:
520 kcal/day * 0.0001555 kg/kcal + 0.1174 kg/day ~=  0.2 kg/day

Not bad at all, and its supported by the fact that really I lost 7kg in 34days. 7/34 = 0.20!

Do I lose weight the same day that I 'starve'?
Question 2 is remaining: Is it happening the same day?
Short answer: Yes. Long answer: Yes, but there might be a lag and prolonged effect for sport activities. The evidence in a picture:
Direct impact of 'fasting'
Size of points representing calories left to base-rate
The higher the line, the greater the weight-loss.
A calorie point sits on the weight-loss recorded the morning after.
That is: the loss-spike is caused by the calorie point it carries.


Often a bigger point sits on a higher spike, which leads to the satisfactory conclusion that indeed you lose the kilos the same day as you restrict your calorie intake. The big outlier we saw already before has a different behavior. Here, the big balls hang relatively low. Does sport have a weight loss lag? The mythical regeneration phase?

The days my sport activity burned more than 1000kcal: 
Day 12: 1587 kcal
Day 13: 1946 kcal
Day 29: 1099 kcal
This big outlier on day 12 and 13 could cause a after-burner effect, but the evidence is thin. 
More data needed!

Thursday, July 21, 2011

Exponentially Smoothed Diet

Body weight prediction based on irregular measurements over five weeks.
Green is the predicted path in the next ten days.
Exponential smoothing is a technique that can be applied to time series data, either to produce smoothed data for presentation, or to make forecasts. The time series data themselves are a sequence of observations. The observed phenomenon may be an essentially random process, or it may be an orderly, but noisy, process. Whereas in the simple moving average the past observations are weighted equally, exponential smoothing assigns exponentially decreasing weights over time.
[http://en.wikipedia.org/wiki/Exponential_smoothing]


I applied Exponential smoothing to the time series I obtained from my livestrong.com recordings. Of course I have the highest motivation to beware this noble technique from being wrong.
Find all the R code and data below.

Saturday, July 16, 2011

Lies, Damn Lies and Diets

The simplest diet that works is to eat not more calories than you spend. Each day. I experimented with livestrong's myplate, a slick calorie counter.
You enter the food that you ate - "penne alla arrabiata - 100g". You enter the exercise or tasks - "computer work - 480 min" and you can instantly figure out your remaining calorie budget.
It's addicting!
Furthermore it's an effective example how a quantitative approach resolves a problem.

My strongest believe is that one should pay more attention to the genuine scientific question: "How much it is?" than to the genuine philosophical question: "What is it?". Size does matter. All diets are deeply 'philosophical' in this sense, they try to answer the question of what to eat instead of how much. Contrary to this approach you have to start with the amount of calories first, and then - in order to eat enough without spending too much of your calorie budget - you learn to choose food that is calorie-cheap. You eat the vegetable dish and not the pizza. When having a calorie rich plate, you simply eat less. Don't be afraid of throwing half of a Magnum Dark Chocolate Icecream away.

Do you see how big the correlation coefficient R must be here? Linear weight loss, sans famine.

Tuesday, July 12, 2011

Italy's self-financed debt?

If national debt is financed by its own households, according to common wisdom the exposure is not problematic. Italy has traditionally a high saving rate, and the national banks advertise government bonds appealingly.
Probably a good share of household savings go into BOT, BCT etc.
But the saving rate has diminished  from >16% to 7.4% in the last twenty years.
When experts bring up the high saving rates argument, I can't trust them.

http://www.gfmag.com/tools/global-database/economic-data/10396-household-saving-rates.html#axzz1RpkjkzTb

Friday, June 10, 2011

A Foundation of Measurement

Do you think Math is the science of measurement?
I am not sure about it, but I know a mathematician who is a radical philosopher of measurement and next week I am going to meet him. Thomas Saaty is an Iranian-American professor of mathematics who goes to the core of it. The comparision is both predecessor and generalization of measurement. The pairwise comparison theory of Prof. Saaty is a reconciliation of mathematics and psychology. With the precise understanding of pairwise comparison you can make an abundance of rational decisions. From picking the right software to
Palestine-Israeli peace process. Ok,... at least we try!
See you at http://www.isahp.org/italy2010

Tuesday, May 17, 2011

The Kondratjev Epedemy

Somehow this thing called  "Kondratjeff Wave" is stubborn. I encounter it frequently when the occassionaly business related speaker crosses my path. The idea of Nicolai Kondratjev was that the regular business cycles of boom and bust are overlayed by sixthy year super cycles. The problem with business cycles is that they can not be predicted, we know that there is a boom and then eventualy a bust. We don't know how long a boom stays and when and how long the bust takes. Thats a fact, otherwise the market actors would antecipate each phase change and therefore modify the phases. You see, its unpredictability is native to the markets. Therefore "cycle" might be a term taken with a grain of salt: its periodicity is not constant nor predictable. Now Kontradieff made his proposal of Supercycle 1929 and he figured out three cycles in history. The observation of an invariance of three cycles really means nothing statistically speaking. Take the US GDP per capita since 1961, and tell me where the cycles are?
The six Kondratieff Cycles
we should have witnessed in the past century

Kondratieff Cycles - hard to spot: remember, they are sixty year periods. It just doesn't fit

Ok, If this is convincing, why the Kondratieff spreads like a virus?
  1. A regular cycle of boom and bust is a persuasive idea.
  2. We are acquainted with the notion of "epoch" and Kondratieff is a visual representation of the "epoch". Therefore by analogy we understand the concept, it is sound. But conclusions drawn from analogy are not waterproof logical operations. They are merely hints.  
  3. The host of the meme has the opportunity to show technical skills (it looks kind of scientific) and demonstrate deeper insight into long term mechanics of human condition. What an opportunity for the host.
  4. The witnesses of the meme have the succumb to 1 and 2 and humans are such pattern addicts, they can not resist the temptation to see a regularity.
We need to implant a new meme that represents the truth:
Kontradieff is bogus, they want to fool you with business esoterics.
I have hope for this brand new meme, humans are ashamed of being tricked. 

Sunday, May 15, 2011

How to decide when more than one criteria is important: ELECTRE

The French School of decision making has a short answer: Apply an ELECTRE algorithm.
Howto:

  1. Decide what to compare, e.g. products, actions
  2. Define criteria and their scales, importance and veto tresholds (I'd rather die, than choosing a hotel without Internet connection)
  3. Measure them
  4. Construct outranking relations, in the style of  a better b if. These are called Recommandations.
  5. Devise an exploitation procedure that uses the Recommandations to e.g. rank the products.
Sounds promising, after a day of research I must give up because the material found on internet is hard to grasp. But the americans, much more elegalitarian when offering ideas, are doing good job with Analytical Hierarchical Process. Subject under investigation and my next post.

    Thursday, April 14, 2011

    Expert Bias and Making a Screencast 'better'

    I've updated the screencast tutorial for EPR. Even if I augmented the quality of the recording, I have the bad feeling that I've complicated the explaination. Dan and Chip Heaths "Made to Stick" argues that experts fail to teach, because they focus too much on 'important' details. So eventually I have to do it again.

    Sunday, April 10, 2011

    How to Solve It! A book review

    "Schule des Denkens"  means school of thought. The title of the original manuscript reveals the motivation for this book: to teach better. George Polya wrote it as a guide on how to lecture mathematics. But only the publicized edition, after Polya's migration to the United States, tells in plain English why its relevant for a broader audience: How to Solve ItI am not a teacher, the didactic musings of a lecturer would produce nothing more than a spark of curiosity in me. But "How to Solve It" describes a general procedure for problem solving. This freaks me out! Polya hides this endeavor in favor of the didactic justification, and only later in this book he will reveal that it is about a Modern Heuristic, to "understand the process of solving problems, especially the mental operations typically useful in this process" [p. 129]. The book is divided into four parts, I will discuss them briefly:
    Part I: In the Classroom
    This 32 pages are all you need to grasp his algorithm of problem solving. Good ideas are simple and the procedure proposed is not counterintuitive. You could easily come a similiar conclusion by your own:
    What is the first step of problem solving? 
    (1) Understanding the problem. 
    What is the next step? 
    (2) Devise a plan. 
    Then?
    (3) Execute the plan. 
    And finally
    (4) Look back
    Mightily impressed? Then you are a lobotomized PowerPoint disciple! But follow Polya in a Socratic dialog with the classroom and look into the train of thoughts of an educated problem solver. There are many subtilities to discover.
    By reading this chapter, more than once I had moments of Heureka!when Polya guides you to ask the so called right questions and instructs you how to take a different point of view of the problem.
    Part II: How to Solve it - a Dialog
    The second part compresses the problem solving procedure, the ars inveniendi, in a summary of two pages. I did not gain from this, but it might be helpful as a short rehearsal when time passes by.
    Part III: Dictionary of Heuristic
    This is a 200 pages collection of heuristics to use as a pattern language for problem solving. The autor advices to take your time read this piece by piece when you are struggling with problems. Which I do.
    Part IV: Problems, Hints, Solutions
    These 8 pages are filled with exercises and smart hints how to approach the individual problems.
    Conclusions
    Polya opens your mind for solutions. I will tackle future hard problems only with Polya's algorithm and benefit from the careful order he imposes to the confused mind.
    Albeit written for teaching mathematics, I suspect that Polyas work is useful not only for quantitativ problem solving, but for qualitative problems too. Here, I have no proof and only the application of it will tell. 
    The book is easy to read, and you might master the first fundamental part "In the Classroom" in 3-5 hours. It is also a really cheap book, 13-something Euros, and if you are a problem solver you will need and enjoy it.

    Wednesday, March 30, 2011

    Fully Automated Prediction with Random Forests

    Put the input vector down each of the trees in the forest. Each tree gives a classification, and we say the tree "votes" for that class. The forest chooses the classification having the most votes (over all the trees in the forest).
    Basically Random Forests automatically generate many decision trees with mostly weak predictive goodness, and gain high predictive power by averaging them out. The algo can be sketched like this:
    1. randomly sample variables and predictors, repeat:
      1. identifying a predictor
      2. repeat down the tree
        1. seeking the most correlated variable
        2. make a binary decision out of it
    2. combine all predictions and average them out, voila!

    Result: high predictive goodness sans parameters!

    http://stat-www.berkeley.edu/users/breiman/RandomForests/

    Tuesday, March 15, 2011

    Switching of the Nuclear Powerplants in Germany now?

    Today chancellor Merkel announced to switch of  7 nuclear power plants as a consequence of the fukushima catastrophe.
    The decision means cutting 10% to 15% of Germanys power consumption, using the net power production median of the weakest nuclear powerplants (890 MW) and the median of the overall powerplants (1288 MW)

    Update: they named the plants in question


    de.wikipedia.org/wiki/Liste_der_Kernreaktoren_in_Deutschland
    UnterweserKKUNI NIE.ON1.4101.345


    Biblis BKWB BHE HERWE1.3001.240








    Biblis AKWB AHE HERWE1.2251.167








    Philippsburg 1KKP 1BW BWEnBW926890
    Isar/Ohu 1KKI 1BY BYE.ON912878
    Neckarwestheim 1GKN 1BW BWEnBW840785








    BrunsbüttelKKBSH SHVattenfall806771








    These have a net power of 771+785+878+890+1167+1240+1345= 7076 MW or 11.3% of annual consumption.

    Update: the last data on power trade balance shows a surplus of 22 TWh