Wednesday, 20 April 2016

Water Water Everywhere and Not a Drop to Drink -Making Use of Social Media Data (Part 1)



The ancient Greek philosophers Plato and Aristotle may seem like the quintessential Dead White Males, but in fact they’re very much alive. Twenty four centuries ago they laid the foundations of Western culture, and their ideas and insights still dictate essential features of our world right now, from what we eat to what we see on the internet.


Forget right brain/ left brain, neuroscientist debunked that theory years ago. And even forget men from mars and women from Venus. The real split that shapes our lives, our relationship and our culture is between our inner Plato and inner Aristotle.


Plato was a typical playboy from a wealthy, connected Athenian family until he met a man named Socrates, who taught him that the surest path to wisdom was rational contemplation, and that being a “lover of wisdom” or philosopher was the highest form of life.


Plato taught his students that all of us want to be part of something higher, a transcendent reality of which the world we see is only a small part, and which unites everything into a single harmonious whole. All of us, he said want to crawl out of the cave of darkness and ignorance, and walk in the light of truth.“There is no other road to happiness,” Plato concluded, “either for society or the individual” 
 
Plato’s most brilliant pupil, however arrived at a very different view. Growing up in a family of Greek physicians, Aristotle learned early on the value of observation and hands-on experience. We don’t live in a cave, was his reply to Plato; we live in the real world. “Facts are the starting point” of all knowledge, Aristotle wrote. So instead of accepting his teacher’s belief in pure contemplation, Aristotle said our path to knowledge comes through logical, methodical discovery of the world around us-and facts that make it up.


Aristotle asks: “How does it work?” Plato asks: “Why does it exist at all?”


Plato asks, “What do you want your world to be?” Aristotle asks, “How do you fit into the world that already exists?”


Plato asks, “What’s your dream? “ Aristotle replies, “Wake up and smell the coffee”.


Two different world-views: one great debate. Personally I think like Aristotle and I will pose similar questions in respect to Social Media. “Why does Social media exist?” and “How does your brand fit in the Social media world?” 


Well, this article is about Social media and how we can get meaningful data from Social Media (Twitter and Facebook) and use it to understand better our targets. (Customers and public opinion on brands for Marketers and Voters/Public opinion for politicians).

When I started mining data from Facebook using R I was doing it for fun. I was amazed by the ability to connect R with Facebook API and the potential held by the data I could retrieve. As a novice in Social media analysis I created some simple apps using Shiny (A package in R to build web based apps) which were fun to play with. 

I will share with you one app, I call it "The Facebook App" . It connects R with Facebook , R sends a request to Facebook API to get the list of pages the user has liked (The APP user). The Facebook API responds by allowing R to get the requested data in form of a Data frame. R writes the data frame into a .csv (comma separated format) file which you can download and view the list of pages you have liked.  You can follow this link to try the app https://gabrielmutua.shinyapps.io/facebook-App/ 

Later on I worked on project were I mined text Data on Twitter and performed Sentiment Analysis on it. It was interesting project and I learned a lot. I will share more on my past projects another day. I want to focus(on next series of blogs) on importance of social media data in understanding the target group/market.

In today’s world of social media and the wide variety of social media channels available, there is a huge amount of data available. The challenge comes in accessing that data and transforming it into something that is usable and actionable.

There are three major approaches to looking at social media: channel reporting tools, overview score- carding systems and predictive analytic techniques (primarily text mining). Each has its useful aspects, but each also has limitations.
  
In the next post I will discuss a fourth approach using a predictive analytic platform that includes not only text mining, but network analysis as well as other predictive techniques such as clustering to overcome not only the limitations of the previous techniques, but generate new fact based insight as well. I will use data mined from Twitter so be ready to learn something new.

 

Sunday, 15 March 2015

R DATA ANALYSIS USING LOGIT REGRESSION

It has been long time since I updated my blog and this has caused disappointment to some of my fans who have added my blog to their RSS feed and have been expecting a new post. It was a wonderful feeling to get  feedback from some of the readers.(Man Vic and the rest Asante Sana).

This new post deals with doing logit regression in R and interpreting the model result. Suppose that we are interested in the factors that influence whether a political candidate wins an election. The outcome (response) variable is binary (0/1); win or lose. The predictor variables of interest are the amount of money spent on the campaign, the amount of time spent campaigning negatively and whether or not the candidate is an incumbent. This is an example of situation that can be modeled using logit regression.


Logistic Regression gives the probability associated with each category or each individual outcome.  The probability function is joined with the linear equation using probability distribution. In Logistic Regression we use binomial distribution where we work on two category problems.Logistic regression, also called a logit model, is used to model dichotomous outcome variables. In the logit model the log odds of the outcome is modeled as a linear combination of the predictor variables.

Assume we are interested in how variables, such as GRE (Graduate Record Exam scores), GPA (grade point average) and prestige of the undergraduate institution(For example UoN is more prestigious than most of other public universities), effect admission into graduate program e.g PWC Undergraduate Training. The response variable, admit/don't admit, is a binary variable.

For our data analysis below, we are going to expand on this example about getting into graduate program. We have generated hypothetical data, which can be obtained from this link View/Download the data Note that R requires forward slashes (/) not back slashes (\) when specifying a file location even if the file is on your hard drive. When the file is opened in Google drive download it and read it in R using read.csv() function. For a person who is not used to R Download the data and move it to document folder if you are using windows . This is default directory of R and you can read it using this simple command.

mydata <- read.csv("myBinaryData.csv").
## view the first few rows of the data
head(mydata)

##   admit gre  gpa rank
## 1     0 380 3.61    3
## 2     1 660 3.67    3
## 3     1 800 4.00    1
## 4     1 640 3.19    4
## 5     0 520 2.93    4
## 6     1 760 3.00    2

This dataset has a binary response (outcome, dependent) variable called admit. There are three predictor variables: gre, gpa and rank. We will treat the variables gre and gpa as continuous. The variable rank takes on the values 1 through 4. Institutions with a rank of 1 have the highest prestige, while those with a rank of 4 have the lowest. We can get basic descriptives for the entire data set by using summary. To get the standard deviations, we use sapply to apply the sd function to each variable in the dataset.

summary(mydata)

##            admit            gre           gpa            rank    
##  Min.        :0.000   Min.      :220   Min.   :    2.26   Min.   :  1.00 
##  1st Qu .  : 0.000   1st Qu.:  520   1st Qu. :  3.13   1st Qu.: 2.00 
##  Median   :0.000   Median    :580   Median  :3.40   Median : 2.00 
##  Mean      :0.318   Mean   :   588   Mean   :  3.39   Mean   :  2.48 
##  3rd Qu .  :1.000   3rd Qu.:   660   3rd Qu.:  3.67   3rd Qu. : 3.00 
##  Max.       :1.000   Max.   :    800   Max.   :   4.00   Max.     :4.00

sapply(mydata, sd)

##   admit     gre     gpa    rank
##   0.466 115.517   0.381   0.944


## two-way contingency table of categorical outcome and predictors we want
## to make sure there are not 0 cells
xtabs(~admit + rank, data = mydata)
##      rank
## admit  1  2  3  4
##     0 28 97 93 55
##     1 33 54 28 12

Analysis methods you might consider

Below is a list of some analysis methods you may have encountered. Some of the methods listed are quite reasonable while others have either fallen out of favor or have limitations.
  •  Logistic regression, the focus of this page
  • Probit regression. Probit analysis will produce results similar logistic regression. The choice of probit versus logit depends largely on individual preferences
  • OLS regression. When used with a binary response variable, this model is known as a linear probability model and can be used as a way to describe conditional probabilities. However, the errors (i.e., residuals) from the linear probability model violate the homoskedasticity and normality of errors assumptions of OLS regression, resulting in invalid standard errors and hypothesis tests. For a more thorough discussion of these and other problems with the linear probability model, see Long (1997, p. 38-40)
  • Two-group discriminant function analysis. A multivariate method for dichotomous outcome variables
  • Hotelling's T2. The 0/1 outcome is turned into the grouping variable, and the former predictors are turned into outcome variables. This will produce an overall test of significance but will not give individual coefficients for each variable, and it is unclear the extent to which each "predictor" is adjusted for the impact of the other "predictors."
Using the logit model
The code below estimates a logistic regression model using the glm (generalized linear model) function. First, we convert rank to a factor to indicate that rank should be treated as a categorical variable.

mydata$rank <- factor(mydata$rank)
mylogit <- glm(admit ~ gre + gpa + rank, data = mydata, family = "binomial")

Since we gave our model a name (mylogit), R will not produce any output from our regression. In order to get the results we use the summary command.

summary(mylogit)

##
## Call:
## glm(formula = admit ~ gre + gpa + rank, family = "binomial",
##     data = mydata)
##
## Deviance Residuals:
##    Min      1Q  Median      3Q     Max 
## -1.627  -0.866  -0.639   1.149   2.079 
##
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)   
## (Intercept) -3.98998    1.13995   -3.50  0.00047 ***
## gre          0.00226    0.00109    2.07  0.03847 * 
## gpa          0.80404    0.33182    2.42  0.01539 * 
## rank2       -0.67544    0.31649   -2.13  0.03283 * 
## rank3       -1.34020    0.34531   -3.88  0.00010 ***
## rank4       -1.55146    0.41783   -3.71  0.00020 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
##     Null deviance: 499.98  on 399  degrees of freedom
## Residual deviance: 458.52  on 394  degrees of freedom
## AIC: 470.5
##
## Number of Fisher Scoring iterations: 4

  • In the output above, the first thing we see is the call, this is R reminding us what the model we ran was, what options we specified, etc.
  • Next we see the deviance residuals, which are a measure of model fit. This part of output shows the distribution of the deviance residuals for individual cases used in the model. Below we discuss how to use summaries of the deviance statistic to assess model fit.
  • The next part of the output shows the coefficients, their standard errors, the z-statistic (sometimes called a Wald z-statistic), and the associated p-values. Both gre and gpa are statistically significant, as are the three terms for rank. The logistic regression coefficients give the change in the log odds of the outcome for a one unit increase in the predictor variable
    • For every one unit change in gre, the log odds of admission (versus non-admission) increases by 0.002
    • For a one unit increase in gpa, the log odds of being admitted to graduate school increases by 0.804
    • The indicator variables for rank have a slightly different interpretation. For example, having attended an undergraduate institution with rank of 2, versus an institution with a rank of 1, changes the log odds of admission by -0.675
  • Below the table of coefficients are fit indices, including the null and deviance residuals and the AIC. Later we show an example of how you can use these values to help assess model fit .
We can use the confint function to obtain confidence intervals for the coefficient estimates. Note that for logistic models, confidence intervals are based on the profiled log-likelihood function. We can also get CIs based on just the standard errors by using the default method.

## CIs using profiled log-likelihood
confint(mylogit)

## Waiting for profiling to be done...
##                 2.5 %   97.5 %
## (Intercept) -6.271620 -1.79255
## gre          0.000138  0.00444
## gpa          0.160296  1.46414
## rank2       -1.300889 -0.05675
## rank3       -2.027671 -0.67037
## rank4       -2.400027 -0.75354

## CIs using standard errors

confint.default(mylogit)

##                2.5 %   97.5 %
## (Intercept) -6.22424 -1.75572
## gre          0.00012  0.00441
## gpa          0.15368  1.45439
## rank2       -1.29575 -0.05513
## rank3       -2.01699 -0.66342
## rank4       -2.37040 -0.73253

We can test for an overall effect of rank using the wald.test function of the aod library. The order in which the coefficients are given in the table of coefficients is the same as the order of the terms in the model. This is important because the  wald.test function refers to the coefficients by their order in the model. We use the wald.test function. b supplies the coefficients, while Sigma supplies the variance covariance matrix of the error terms, finally Terms tells R which terms in the model are to be tested, in this case, terms 4, 5, and 6, are the three terms for the levels of rank.

#installing aod package
install.packages("aod")


#loading aod package
library(aod)

wald.test(b = coef(mylogit), Sigma = vcov(mylogit), Terms = 4:6)

## Wald test:
## ----------
##
## Chi-squared test:
## X2 = 20.9, df = 3, P(> X2) = 0.00011

The chi-squared test statistic of 20.9, with three degrees of freedom is associated with a p-value of 0.00011 indicating that the overall effect of  rank is statistically significant.

We can also test additional hypotheses about the differences in the coefficients for the different levels of rank. Below we test that the coefficient for rank=2 is equal to the coefficient for rank=3. The first line of code below creates a vector l that defines the test we want to perform. In this case, we want to test the difference (subtraction) of the terms for rank=2 and rank=3 (i.e., the 4th and 5th terms in the model). To contrast these two terms, we multiply one of them by 1, and the other by -1. The other terms in the model are not involved in the test, so they are multiplied by 0. The second line of code below uses L=l to tell R that we wish to base the test on the vector l (rather than using the Terms option as we did above).

l <- cbind(0, 0, 0, 1, -1, 0)
wald.test(b = coef(mylogit), Sigma = vcov(mylogit), L = l)

## Wald test:
## ----------
##
## Chi-squared test:
## X2 = 5.5, df = 1, P(> X2) = 0.019

The chi-squared test statistic of 5.5 with 1 degree of freedom is associated with a p-value of 0.019, indicating that the difference between the coefficient for rank=2 and the coefficient for rank=3 is statistically significant.

You can also exponentiate the coefficients and interpret them as odds-ratios. R will do this computation for you. To get the exponentiated coefficients, you tell R that you want to exponentiate (exp), and that the object you want to exponentiate is called coefficients and it is part of mylogit (coef(mylogit)). We can use the same logic to get odds ratios and their confidence intervals, by exponentiating the confidence intervals from before. To put it all in one table, we use cbind to bind the coefficients and confidence intervals column-wise.

## odds ratios only
exp(coef(mylogit))

## (Intercept)         gre         gpa       rank2       rank3       rank4
##      0.0185      1.0023      2.2345      0.5089      0.2618      0.2119

## odds ratios and 95% CI
exp(cbind(OR = coef(mylogit), confint(mylogit)))

## Waiting for profiling to be done...
##                 OR   2.5 % 97.5 %
## (Intercept) 0.0185 0.00189  0.167
## gre         1.0023 1.00014  1.004
## gpa         2.2345 1.17386  4.324
## rank2       0.5089 0.27229  0.945
## rank3       0.2618 0.13164  0.512
## rank4       0.2119 0.09072  0.471

Now we can say that for a one unit increase in gpa, the odds of being admitted to graduate school (versus not being admitted) increase by a factor of 2.23. For more information on interpreting odds ratios see INTERPRETING ODDS RATIO How do I interpret odds ratios in logistic regression? . Note that while R produces it, the odds ratio for the intercept is not generally interpreted.

On the next post I will explain how to  use predicted probabilities to help you understand the model. For now bye and heads up a new version of R is out (3.1.3). Cheers!!!!

Adapted from Institute of Digital Research and Education UCLA






Monday, 22 September 2014

WELCOME TO R SIDE OF LIFE


We have many programming languages many build with different capabilities but we can all agree that most languages are multipurpose.(e.g. you can build a simple calculator using all/almost all programming languages), but when it comes to statistical programming R is the King. What is R ? R is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories (formerly AT&T, now Lucent Technologies) by John Chambers and colleagues. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R. I know you may be bored by this R and S language so this is my deal. I want you to follow up as I do/we do a simple statistical analysis on data obtained from WHO on TB burden estimate. To be specific we will analyze the estimated incidence of all types of TB in Kenya from 1990 to 2012.
This is what we are going to do in steps.
  1. We will download the data from WHO website.
  2. Upload it in R 
  3. Do some statistical analysis with the data 

Downloading the data

You can download data in R in different formats. This means data contained or saved using other programs such as SPSS and Excel can be easily be imported into R. In this case I would love to download my data directly into my disk and finally upload it to R. Note it’s also possible to download data directly into R (I will show you right now). My data is in CSV format (comma separated variable) which is one of the best formats to work with. Go to https://extranet.who.int/tme/generateCSV.asp?ds=estimates and download the data. (If you have installed R in Windows the default working directory (folder) is Documents so for those who have problem in specifying file path I would recommend you to move that file to Documents). You can get the working directory by typing this command getwd(). You can also set your working directory using this command setwd(“specify directory(folder)  path in here”). For those who would love to download the data directly try this. > data.all = read.csv(“https://extranet.who.int/tme/generateCSV.asp?ds=estimates.csv”, header = T, sep = “,”)

Uploading data in R

Now we have our data already downloaded so let us get it loaded into R before we dive in the fun of doing statistical analysis. Before then let us look the data.(Comma separated files (.csv) can be opened using Microsoft Excel or any other spreadsheet program) You would realize it us 4905 rows and 39 columns(All the countries of the world are represented from Afghanistan to Zimbabwe  each having 23 rows).
If you have moved your data into your working directory the code is very simple.
> data.all = read.table("TB_burden_countries_2014-09-23.csv", header = T, sep = ",")

If not it’s still simple , assuming you never moved the file from downloads (in windows) you can use this code.
> data.all = read.table("C:/Users/"YOurcompname"/Downloads/TB_burden_countries_2014-09-23.csv", header = T, sep = ",")

Doing statistical analysis on the data

Good now we have our data so let me show you why I call R the king of statistical programming. Since we have downloaded the whole worlds data (TB burden estimates ) . Let us specifically get the Kenyans data from this whole data. For new comers just follow me for those who are already familiar with R I will have to mention that R imports data with many variables as a data frame. If you look carefully you will find that Kenya data is on rows 2284 to 2306. This is how I will get it using this command.
>data.kenya = data.all[c(2284:2306),]  
 
I have used a technique called indexing to put together the rows which contain Kenyan data from data.all and assigned them to the object data.kenya. We can check the dimensions and structure of our new data.kenya using this codes.
>dim(data.kenya)     AND      >str(data.kenya)
 
 
We can also view the data using this code >View(data.kenya)
Note, I am using Rstudio data view on large window.

The real work


My objective is to determine whether there is a relationship between years and Estimated number of incident cases (all forms) which is the variable (column) abbreviated as e_inc_num. With all data analysis the first step is always to explore the data. In this case, scatter plots are very useful in determining whether or not the relationships between the variables are linear.
Let us plot a simple scatter plot using this code:
>plot(data.kenya$year, data.kenya$e_inc_num)

Before proceeding further let us attach our data so that we can refer our variables without having to specify the data frame where they come from. I mean
>attach(data.kenya)
 We can plot the same scatter plot using this code:
>plot(year, e_inc_num)

The above command gives a simple scatter plot with the first variable on the horizontal axis and the second on the vertical axis.
The scatter plot needs to be beautifully represented just copy paste this code into R and enter I will explain it now.
>plot(year, e_inc_num, main = "Relationship Btn Yrs and No of TB Incidences ", col.main = "red", sub = "Kenya", col.sub = "blue" ,xlab = "Years", ylab = "No of TB Incidences",col.lab = "red", pch = 13, col = "red")

                                                                                
The main = Title of the plot, col.main = the color of main, sub = subtitle of the plot, col.sub = the color of subtitle, xlab and ylab = name of x axis and y axis respectively, col. Lab = color of  axis, pch = The shape of the dots(change it to any number), col = color of the dots.
Now that we have our plot let us try to fit a linear model to this data of ours

Fitting linear model

The function lm is used to perform linear modeling in R .Use the code below to create the linear model.
>linear.kenya = lm(e_inc_num~ year)

Displaying the model by typing 'linear.kenya' gives limited information. To get more information, one can look at the attributes of this model, its summary and attributes of its summary.
>attr(linear.kenya,"names")

[1] "coefficients"  "residuals"     "effects"     
 [4] "rank"          "fitted.values" "assign"      
 [7] "qr"            "df.residual"   "xlevels"     
[10] "call"          "terms"         "model

There are 12 attributes. Most of them can be displayed with the summary function.
lm(formula = e_inc_num ~ year)

Residuals:
   Min     1Q Median     3Q    Max
-25554  -9658  -1761  11272  21500

Coefficients:
              Estimate Std. Error t value Pr(>|t|)   
(Intercept) -1.037e+07  8.588e+05  -12.08 6.44e-11 ***
year         5.228e+03  4.292e+02   12.18 5.51e-11 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 13650 on 21 degrees of freedom
Multiple R-squared:  0.876,    Adjusted R-squared:  0.8701
F-statistic: 148.4 on 1 and 21 DF,  p-value: 5.51e-11

The first section of summary shows the formula that was 'called'. The second section gives the distribution of residuals. The pattern is clearly not symmetric. The maximum is too far on the right (21500) compared to the minimum (-25554) and the first quartile is further left(-9658) of the median(-1761) than the third quartile(11272) is. For those who are not statisticians I know this is boring let me leave . Statisticians can go deeper and analyze this  results deeper.

Regression line, fitted values and residuals

A regression line can be added to the scatter plot with the following command:
>abline(linear.kenya)


The expected value is the no of expected TB incidences estimated from the regression line using a specific year.
>points(year, fitted(linear.kenya), pch=18, col="blue")


A residual is the difference between the observed and expected value. The residuals can be drawn by the following command.
>segments(year, e_inc_num, year, fitted(linear.kenya), c="pink")


The actual values of the residuals can be checked from the specific attribute of the defined linear model.

>kenyamodelresduals = residuals(linear.kenya)
> kenyamodelresduals

         1          2          3          4          5
  2467.391  -1760.870  -5989.130  -8217.391  -9445.652
         6          7          8          9         10
-10673.913  -9902.174  -8130.435  -4358.696   1413.043
        11         12         13         14         15
  6184.783  11956.522  16728.261  21500.000  16271.739
        16         17         18         19         20
 21043.478  15815.217  10586.957   5358.696  -9869.565
        21         22         23
-15097.826 -20326.087 -25554.348



The sum of the residuals and the sum of their squares can be checked.
> sum(kenyamodelresduals)
[1] -2.728484e-12
> sum(kenyamodelresduals^2)
[1] 3914228261

The sum of residuals is close to zero whereas the sum of their squares is the value previously displayed in the summary of the model. The distribution of residuals, if the model fits well, should be normal. A common sense approach is to look at the histogram.
>hist(kenyamodelresduals)
 Based on the number of observations it can be hard to say that the residuals are normally distributed . I would love to first leave you on this point to make your own conclusions. I would come later to tell how to interpret the results clearly and accurately.

Monday, 18 August 2014

CHILD EDUCATION POLICY


The child education policy is a life insurance product specially designed as a savings tool to provide an amount of money when your child reaches the age for entry into college (18 years and above). The funds can be used to pay for your child's higher education expenses. Under this policy, the child is the life assured, while the parent/legal guardian is the policy owner. 
If you opt for a payor benefit rider, the education policy also provides assurance that, in the event of the policy owner's untimely demise, the child will have access to the funds to help finance his or her studies.
Why do you need child education plan?
The cost of higher education is increasing. The need for access to higher education and the cost will put a financial strain on you and your family. That is why it is important to start planning for your child's education as soon as possible, because the earlier you begin, the more time you allow your money to grow. The child education policy will provide the funds needed by your child to pursue further education and assures that whatever happens in the future, your child will still have the means to pursue some of his/her goals in life
When choosing plan:

When choosing a policy, always:
1)Consider how much money you want to set aside for your child’s education.
2)Make sure that the premium is affordable.
3)Choose a policy that gives you flexibility so you can gradually increase the savings in the future
4)Ensure you opt for the payor benefit rider

Basic types of policies
      1)Endowment policy
  a)An endowment policy combines a savings component with protection coverage
  b) Endowment policies may be either participating or non-participating
·         Non-participating policies do not participate in the life insurance funds profits but all insurance benefits are fully guaranteed
·         Participating policies have a portion of insurance benefits guaranteed, however the total amount of benefits at maturity is not guaranteed because it depends on the insurance company’s life insurance fund’s performance
     2)Investment-linked policy
     a)  An investment-linked policy combines the elements of investment and protection based on your requirement as the policy owner
     b)  It offers flexibility as you are able to increase or top-up your monthly premium contribution as your income improves. You may also be more aggressive with your investment
     c) An investment-linked policy will allow you to choose the types of funds your money will be invested in. However, like any other investment, there are risks involved and there is no guarantee on the returns, which may be higher or lower than the amount projected

Saturday, 21 June 2014

Income Inequality



I want today to discuss about wealth and income inequality here in Kenya, using the same arguments as used in  "Capital in the Twenty-First Century".  Capital in the Twenty-First Century is a book by French economist Thomas Piketty. It focuses on wealth and income inequality in Europe and the US since the 18th century. It was initially published in French in 2013, with an English translation released in April 2014. Though the book uses data from Europe and US after looking at points represented in it it’s clear that here in Kenya the  situation is not very much different and we can comfortably use it to understand the sources and effects of wealth and income inequality.
The general presumption of most inequality researchers has been that earned income, usually salaries, is where all the action is, and that income from capital is neither important nor interesting. Piketty shows, however, that even today income from capital, not earnings, predominates at the top of the income distribution. He also shows that in the past—during Europe’s Belle Époque and, to a lesser extent, America’s Gilded Age—unequal ownership of assets, not unequal pay, was the prime driver of income disparities. And he argues that we’re on our way back to that kind of society. Nor is this casual speculation on his part. For all that Capital in the Twenty-First Century is a work of principled empiricism; it is very much driven by a theoretical frame that attempts to unify discussion of economic growth and the distribution of both income and wealth. Basically, Piketty sees economic history as the story of a race between capital accumulation and other factors driving growth, mainly population growth and technological progress.
Consider how this worked in Belle Époque Europe. At the time, owners of capital could expect to earn 4–5 percent on their investments, with minimal taxation; meanwhile economic growth was only around one percent. So wealthy individuals could easily reinvest enough of their income to ensure that their wealth and hence their incomes were growing faster than the economy, reinforcing their economic dominance, even while skimming enough off to live lives of great luxury.
And what happened when these wealthy individuals died? They passed their wealth on—again, with minimal taxation—to their heirs. Money passed on to the next generation accounted for 20 to 25 percent of annual income; the great bulk of wealth, around 90 percent, was inherited rather than saved out of earned income. And this inherited wealth was concentrated in the hands of a very small minority: in 1910 the richest one percent controlled 60 percent of the wealth in France; in Britain, 70 percent.
No wonder, then, those nineteenth-century novelists were obsessed with inheritance. Piketty discusses at length the lecture that the scoundrel Vautrin gives to Rastignac in Balzac’s Père Goriot, whose gist is that a most successful career could not possibly deliver more than a fraction of the wealth Rastignac, could acquire at a stroke by marrying a rich man’s daughter. And it turns out that Vautrin was right: being in the top one percent of nineteenth-century heirs and simply living off your inherited wealth gave you around two and a half times the standard of living you could achieve by clawing your way into the top one percent of paid workers.
Capital still matters; at the very highest reaches of society, income from capital still exceeds income from wages, salaries, and bonuses. Piketty estimates that the increased inequality of capital income accounts for about a third of the overall rise in US inequality. But wage income at the top has also surged. Real wages for most US workers have increased little if at all since the early 1970s, but wages for the top one percent of earners have risen 165 percent, and wages for the top 0.1 percent have risen 362 percent. Piketty is unconvinced. As he notes, conservative economists love to talk about the high pay of performers of one kind or another, such as movie and sports stars, as a way of suggesting that high incomes really are deserved. But such people actually make up only a tiny fraction of the earnings elite. What one finds instead is mainly executives of one sort or another—people whose performance is, in fact, quite hard to assess or give a monetary value to.
Who determines what a corporate CEO is worth? Well, there’s normally a compensation committee, appointed by the CEO himself. In effect, Piketty argues, high-level executives set their own pay, constrained by social norms rather than any sort of market discipline. And he attributes skyrocketing pay at the top to an erosion of these norms. In effect, he attributes soaring wage incomes at the top to social and political rather than strictly economic forces.
The key point is that when we make the crucial comparison between the rate of return on wealth and the rate of economic growth, what matters is the after-tax return on wealth. So progressive taxation—in particular taxation of wealth and inheritance—can be a powerful force limiting inequality. Indeed, Piketty concludes his masterwork with a plea for just such a form of taxation. Unfortunately, the history covered in his own book does not encourage optimism.
Piketty ends Capital in the Twenty-First Century with a call to arms—a call, in particular, for wealth taxes, global if possible, to restrain the growing power of inherited wealth. It’s easy to be cynical about the prospects for anything of the kind. But surely Piketty’s masterly diagnosis of where we are and where we’re heading makes such a thing considerably more likely. So Capital in the Twenty-First Century is an extremely important book on all fronts. Piketty has transformed our economic discourse; we’ll never talk about wealth and inequality the same way we used to.
The central thesis is that wealth will concentrate if the rate of return on capital (r) is greater than the rate of economic growth (g). Over the long term, Piketty argues, this will lead to the concentration of wealth and economic instability. Piketty proposes a global system of progressive wealth taxes to help create greater equality and avoid the vast majority of wealth coming under the control of a tiny minority. The central thesis of the book is that inequality is not an accident, but rather a feature of capitalism, and can only be reversed through state interventionism. The book thus argues that unless capitalism is reformed, the very democratic order will be threatened. Piketty proposes that an annual global wealth tax of up to 2%, combined with a progressive income tax reaching as high as 80%, would reduce inequality.