# The Utility of Social Preferences in Javascript

This post just contains a fun example of utility indifference curves in a dictator scenario. Basically, I'm just following Charness 2002. The article is an interesting one, showing that people may be more concerned with social welfare (a weighted sum of everyone's payoff) instead of being difference averse (not liking inequality between people's payoffs).

Take the example of a Player B who in a dictator game has to decide a split of money between himself and Player A. A model then for the utility of the splits is the following (where $\pi_a$ is the amount paid to Player A, and $\pi_b$ the amount to B):

$U_B(\pi_a, \pi_b) = (\rho * r + \sigma * s) * x + ( 1 - \rho * r - \sigma * s) * y$

Where

$r = 1$ if $\pi_B > \pi_A$, and $r = 0$ otherwise.

$s = 1$ if $\pi_B < \pi_A$, and $s = 0$ otherwise.

In the graph below, the x-axis represents your payoff, with more payoff towards the right side. The y-axis represents the other player's payoff, with higher values toward the top. Greater utility values are darker, while lower ones are lighter. (Yes, I should probably put this with axis labels and a legend, but it's kind of hard to align it with CSS. =P)

You can tweak the utility equation below, as well as the sliders for the values of $\rho$ and $\sigma$ and the graph will update in real time.

Rho: 0
Sigma: 0

Press the buttons below to generate random examples of competitive, difference averse, or social welfare preferences.

Competitive preferences
happen when $\sigma \leq \rho \leq 0$. With competitive preferences people prefer their payoff to be high compared to others.

Difference aversion
happens when $\sigma < 0 < \rho < 1$. This means that a player both prefers more money and for their payoff to be equal to their counterpart.

Social welfare preferences
happen when $1 \geq \rho \geq \sigma > 0$. With social welfare preferences people prefer money both for themselves and the other player, but prefer more for themselves when they are behind the other player compared to when they're ahead.