# Visualizing Inequalities in a 3-Person Economy

Yesterday, in the course on inequalities, I mentioned (too) briefly the 3-person Economy. I wanted to spend some time in a short post on visualisations of inequalities in such a context. As mentioned in the slides,  it is possible to use a ternary plot representation. In the case where we believe that the scale independence principle makes sense, i.e. $I(\lambda\boldsymbol{x})=I(\boldsymbol{x})$. A distribution of incomes can be represented as a barycenter in an equilateral triangle (also called de Finetti diagram). The midpoint is the equal situation: the three agents share the same wealth. Because of the scale independence property, we can look at distribution of wealth on the simplex. A wealth distribution is a vector $\boldsymbol{\omega}=(\omega_A,\omega_B,\omega_C)$ where each component is one of the (red) distance below. A is on top of the triangle, and the vertical distance is proportional to the wealth of A. The closer to the bottom line, the poorer A is.

To visualize this distribution of wealth, we can use the trifield package. To add the point and the three segments, the code is

tripoint=function(s){
p=s/sum(s)
p1=c(0,s[2]+s[1]/2,s[3]+s[1]/2)/sum(s)
p2=c(s[1]+s[2]/2,0,s[3]+s[2]/2)/sum(s)
p3=c(s[1]+s[3]/2,s[2]+s[3]/2,0)/sum(s)
C <- abc2xy(matrix(p,1,3))
points(C,pch=19,col="red",cex=2)
C1 <- abc2xy(matrix(p1,1,3))
C2 <- abc2xy(matrix(p2,1,3))
C3 <- abc2xy(matrix(p3,1,3))
segments(C1[1],C1[2],C[1],C[2],lwd=2,col="red")
segments(C2[1],C2[2],C[1],C[2],lwd=2,col="red")
segments(C3[1],C3[2],C[1],C[2],lwd=2,col="red")
}

For instance, to visualize the equal case (inequality indices are defined as a distance to this situation)

tripoint(c(1,1,1))

For a case where there is inequality, use for instance

tripoint(c(1,2,3))

# Analyse des Données

Ce vendredi, on fera un TD en analyse des données. En plus des bases en ligne sur un ancien billet, je rajoute deux autres bases.

library(xts)
library(YieldCurve)
data(FedYieldCurve)
maturity <- c(3/12,6/12,1,2,3,5,7,10)
plot(maturity,FedYieldCurve[1],type="b")

load(url("http://freakonometrics.free.fr/titanic.rdata"))

# Inequalities, course 3

Tomorrow, we will discuss inequality indices, from a statistical perspective, and also an axiomatic point of view. In order to illustrate, we will use to following dataset,

> income <- read.csv("http://www.vcharite.univ-mrs.fr/pp/lubrano/cours/fes96.csv",sep=";",header=FALSE)\$V1

Slides can be found online. Since it is the first year I give this course, all comments are welcome…

# Analyse des Correspondances, suite

Hier soir, on voyait comment faire une analyse des correspondances à partir du tableau de contingence. Mais on peut avoir le problème autrement, à partir des individus. Certes, ces derniers ne sont pas observés (vraiment), mais peu importe.

> data(HairEyeColor)
> N = HairEyeColor[,,"Male"] + HairEyeColor[,,"Female"]
> Hair = rep(rep(rownames(N),ncol(N)),
+ as.vector(N))
> Eye =  rep(colnames(N),apply(N,2,sum))
> df = data.frame(Ind=1:sum(N),Hair,Eye)
> tail(df)
Ind  Hair   Eye
587 587 Blond Green
588 588 Blond Green
589 589 Blond Green
590 590 Blond Green
591 591 Blond Green
592 592 Blond Green

# Analyse des Correspondances

Lors du dernier cours d’analyse des données, on était parti sur l’analyse (simple) des correspondance, à partir d’un tableau de contingence, pour deux variables qualitatives,

$\boldsymbol{N}=[n_{i,j}]$

On définit alors les effets marginaux,

$n_{i,\cdot}=\sum_j n_{i,j}$

pour les lignes, et pour les colonnes,

$n_{\cdot,j}=\sum_i n_{i,j}$

# Data Science Training

Last week, I was animating a data science training course, for actuaries. I will try to upload in the next days some additional material, related to questions asked…

# Modeling Incomes and Inequalities

Last week, in our Inequality course, we’ve been looking at data. We started with some simulated data, only a few of them

> library("ineq")
> load(url("http://freakonometrics.free.fr/income_5.RData"))
> (income=sort(income))
[1]  19233  23707  53297  61667 218662

How could we say that there is inequality in this sample? If we look at the wealth owned by the poorest, the poorest person (1 out of 5) owns 5% of the wealth; the bottom two (2 out of 5) own 11%, etc

> income[1]/sum(income)
[1] 0.05107471
> sum(income[1:2])/sum(income)
[1] 0.1140305
> sum(income[1:3])/sum(income)
[1] 0.2555648
> sum(income[1:4])/sum(income)
[1] 0.4193262

If we plot those values, we get Lorenz curve

> plot(Lc(income))
> points(c(0:5)/5,c(0,cumsum(income)/sum(income)),pch=19,col="blue")


# Inequalities, course 2

As mentioned last week, tomorrow, we will work with datasets, and start the part on the econometrics of inequality. I have uploded some slides, but additional concepts and tools will be mentioned on the black board (or on the computer, while coding). We will use some simulated data (mentioned in the slides), as well as us_income, on binned data.

# Somewhere else, part 202

Some posts and article worth reading,

# Charlie

Dessin d’Honoré, tombé mercredi midi (via @Gjpvernant). Source Honoré, et iconovox

# Inequalities, course 1

The afternoon, we will have the first course on Inequalities. Slides are available from here.

# Somewhere else, part 201

Some posts and articles worth reading (now obtained almost automatically from my tweets)

# Quand les chercheurs cherchent leur voie (voix) sur Twitter

Il y a plusieurs semaines (mois?), avec @3wen et @pareto35, on nous avait demandé d’écrire un petit article sur Twitter, et sur l’usage de Twitter dans le monde de la recherche, pour la Newsletter du CREM (Centre de Recherche en Économie et Management, de l’Université de Rennes 1, et de l’Université de Caen). On avait envoyé l’article, et je n’y avais plus pensé. Or cet après-midi, @alisag1728 publiait “25 Interesting Observations About How Academics Use Twitter” qui éclairait le débat, et qui m’a refait pensé à cet article. Comme les discussions semblent à nouveau d’actualité, j’en profite donc pour mettre en ligne la note qu’on avait écrite… Tous les commentaires sont les bienvenus (en gardant en mémoire que l’article était écrit à destination de chercheurs qui entendent peut être parler de Twitter, à l’occasion, mais qui ne voient pas – a priori – pourquoi y être présent).
Continue reading Quand les chercheurs cherchent leur voie (voix) sur Twitter

# Automatic Detection of the Language of a Tweet

Two days ago, in my post to extract automatically my own tweets, and to generate some html list, I mentioned that it would be great if there were a function that could be used to distinguish tweets in English, and tweets in French (usually, I tweet in one of those two languages). And one more time, @3wen came to rescue me! In my previous post, I spent some time to extract mentions to other twitter accounts, and urls. This time, I have to remove those two informations, that are not relevant to get the language of a tweet.