# Consumer Demand¶

Foundations of microeconomics start with how consumers behave. We might want to predict what a consumer is likely to do in a given situation. We might want to make sense of observed behavior. The theory will appear simplistic. But from this simple theory, we will be able to predict pretty well behavior in certain situations. Refinements exist, in particular to allow consumers to be more humans, have biases, cognitive limitations, emotions. Consumer Distributing was a very popular catalogue store chainin Canada and the United States where users would fill orders by looking at a catalogue et filling a form and pick up the goods at a sales point. An ancestor of Amazon at a time where the internet did not exist.

## Preferences¶

Preferences are defined over baskets of goods and services

• Basket: vector of quantities $$x = (x_1, x_2,\cdots,x_n)$$.

• For any baskets $$A$$ and $$B$$, preferences dictate which one is preferred.

• Preferences are just like wish lists. They ignore prices and resources.

• Preference relations are denoted $$\succ,\succeq,\sim$$.

Important assumptions about preferences

Assumptions (or axioms as they are called) on preferences are necessary to yield a theory of how consumers behavior. These axioms yield predictions. Among the most important, we have that they should be:

Exhaustive

For any two baskets A and B, either the consumer:

• prefers always A to B ($$A\succ B$$)

• prefers always B to A ($$B\succ A$$)

• is indifferent between A and B ($$A \sim B$$)

Transitivity

Given three baskets A, B, C such that $$A\succ B$$, $$B \succ C$$, then if transitivity holds he also prefers A to C ($$A \succ C$$).

This assumption appears logical. But it sometimes fails. In particular when uncertainty is present. Yet, we will keep it as it is very important for what follows.

Non-satiation

In its simplest form, this assumption implies that

• If A has the same quantity of each good as basket B, but strictly more of one good, then $$A \succ B$$.

• Weaker version ($$A \succeq B$$,indifference or preference) is reasonable.

• Putting labels on goods so non-satiation makes sense: goods are typically labeled as desirable (air quality instead of pollution).

It is not practical to use wish lists to model behavior. For example, how do we predict how consumers react to price changes using a wish list? We will want to get closer to marginal analysis to make this more practical.

Finally, it is important to note that preferences are very different across consumers. Falk et al. (2018) have analyzed this heterogeneity in 76 countries.

Python lists can be used to study preferences et predict choice, even for discrete items. What will the call to the function choice will return below?

import numpy as np

prefs = ['12 angry men','casablanca','taxi driver','out of africa']

def choix(pair,prefs):
ii = [prefs.index(p) for p in pair]
return pair[np.argmin(ii)]

choix(['out of africa','casablanca'],prefs)


Netflix does study how you rate movies in order to propose new ones to you which you might like. Although the algorithms behind are much more complicated than our simple example, the same idea applies. They learn your preferences by collecting your rating information and able to reduce your search costs and improve user experience. Who said studying preferences could not be cool?

## Indifference Curves and MRS¶

One of the first tools we can construct is indifference curves.

For any two goods $$X,Y$$:

• Starting from a basket $$(X_0,Y_0)$$, find combinations of $$(X,Y)$$ such that the consumer is indifferent between $$(X,Y)$$ and $$(X_0,Y_0)$$

• In the plane ($$X,Y$$), higher indifference curves indicate a preference.

Proposition: If transitivity holds, indifference curves cannot cross.

Todo

Exercise A: Show that this last proposition is correct.

Marginal Rate of Substitution (MRS)

These indifference curves contain more information than we think …

For a basket $$(X_0, Y_0)$$, MRS of $$X$$ in terms of $$Y$$: Quantity of good $$Y$$ the consumer is willing to sacrifice to increase $$X$$ by one unit It is the marginal value the consumer puts on $$X$$ in terms of quantity of good $$Y$$. It corresponds to the slope at $$(X_0,Y_0)$$.

Convexity of indifference curves

If the quantity of $$X$$ increases, how does the MRS for $$X$$ changes?

It decreases generally. This implies convex indifference curves (the slope of the indifference curve decreases as X increases). Even if there is non-satiation, we generally accept that the intensity of preference decreases as the quantity consumed increases.

## Utility¶

Indifference curves allow us to move away from wish lists to a function. On an indifference curve, each basket gives the same level of satisfaction to the consumer (he is indifferent). Let’s fix that level to some arbitrary number, called utility. Jumping from one indifference curve to another change the level of satisfaction. Hence, indifference curves are like level curves on a topological map, they do not cross. The main insight is that we can construct a function $$u(X,Y)$$ which represent these preferences. The value of this function is ordinal, it allows to rank the different indifference curves. It is only this order that counts.

Utility function: assigns a value to each basket. $$u$$ represents these preferences if $$A \succ B \Rightarrow u(A) > u(B)$$ and $$u(A) > u(B) \Rightarrow A \succ B$$ for any two baskets.

This has a number of implications. The main one is that there are many utility functions that represent the same preferences…

If $$f$$ is a strictly increasing transformation (function) and $$u$$ represents some preferences, then $$g(X) = f(u(X))$$ represents the same preferences.

$u(X) > u(Y) \iff f(u(X)) > f(u(Y))$

Important

The value attached to utility does not have a real interpretation, it is the ranking of baskets through the level of these utility levels which matters.

Example: $$u(X,Y) = \log X + \log Y$$ and $$g(X,Y) = XY$$ represent the same preferences.

Todo

Exercise B: Show that $$u$$ and $$g$$ in this example have the same preferences by finding the transformation $$g=f(u)$$.

Todo

Checkout this representation of a utility function with indifference curves at EconGraph.org

How to find the MRS from utility?

• Two goods, $$X$$, $$Y$$. Preferences are represented by $$u(X,Y)$$

• e.g. $$u(X,Y) = \log X + \log Y$$

We can write a more general utility function as:

import numpy as np

def u(x,y,alphas):
return alphas*np.log(x) + alphas*np.log(y)

u(1.0,1.0,[0.5,0.5])


What will the call to u() return?

MRS of $$X$$:

• How much $$Y$$ should one sacrifice to gain $$X$$

• Formally: if we increase $$X$$ by $$\Delta X$$, what is the change $$\Delta Y$$ which maintains indifference?

Let’s calculate the MRS of $$X$$. We can use total differentiation:

\begin{aligned} du = \frac{\partial u}{\partial X}dX + \frac{\partial u}{\partial Y}dY\end{aligned}

Set $$du = 0$$ so that utility is fixed. Then

$\frac{dY}{dX}\bigg\rvert_{du=0} = -\frac{\frac{\partial u}{\partial X}}{ \frac{\partial u}{\partial Y}}$

Important

The MRS mesures the intensity of our preference for a good in terms of the quantity of another good we are willing to sacrifice. The MRS summarizes preferences for two goods and can be compared across consumers. We can also interpret it as a willingness to pay (measured in quantity of goods).

We can write marginal utility functions in Python:

import numpy as np

def mu_x(x,y,alphas):
return alphas/x
def mu_y(x,y,alphas):
return alphas/y


And finally the MRS:

def mrs(x,y,alphas):
umx = mu_x(x,y,alphas)
umy = mu_y(x,y,alphas)
return - umx/umy


Note

In general, it is a good to use the russian puppet principle when programming. You encapsulate functions into functions when those are likely to be re-used but also could be changed without having to change all functions. For example, if we change the utility function, we need to change the mu_x() and mu_y() functions but not the mrs() function.

Todo

Play around with this animation of indifference curves and MRS at Econgraph.org

## Budget Constraint¶

Until now, the consumer has available all baskets and he has preferences over those. In practice, he is limited by the resources he has, each time he has to purchase goods, at some price. Hence, those actions have an opportunity cost.

• One cannot spend more than income (or wealth) $$I$$

• Two goods $$X$$, $$Y$$: Constraint: $$p_X X + p_Y Y \leq I$$. This constraint determines what is available given $$I$$ and prices.

Setting to equality, we can solve for $$Y$$ in terms of $$X$$: $$Y = \frac{I - p_X X}{p_Y}$$

The relative price between $$X$$ et $$Y$$ holding the budget constant is:

$\frac{dY}{dX} = -\frac{p_X}{p_Y}$

Buying a unit of $$X$$ implies a sacrifice of $$\frac{p_X}{p_Y}$$ units of $$Y$$. It is the opportunity cost of $$X$$ in terms of $$Y$$. In the space $$(X,Y)$$, the budget line defines all possible allocation. Those above are not feasible. Those on the line or below are feasible.

Normalization

• The budget constraint remains the same if we multiply prices and income by the same constant $$\lambda$$.

• One can buy the same goods. Hence, currencies do not impact the budget constraint. Only purchasing power and relative prices do.

• Therefore we will sometimes set $$p_Y = 1$$. Then $$Y = I - p_X X$$. $$p_X$$ is in terms of the quantity of $$Y$$ (numéraire) and idem pour $$I$$.

Only relative prices matter.

Todo

Exercice C: Show that the budget constraint does not change if we multiply prices and income by $$\lambda>0$$.

Todo

Play around with this animation of a budget constraint at Econgraph.org

## Consumer choice¶

The constraint is a given and therefore fixed. The consumer can pick on which indifference curve he wants to be and where on that curve. It seems natural to predict that he will want to pick the feasible basket which maximizes his utility.

He can’t go on an indifference curve above the budget line. Those allocations below the budget line cannot be optimal if we have non-satiation. He has money to spare and could spend it on goods which provide (marginal) utility. The indifference curve that touches on the constraint (tangent)gives the highest feasible level of utility. The points A, C et D are possible given the constraint. Therefore, point B can be eliminated even if the MRS (slope at B) is close to the price ratio. Point D can also be eliminated because the consumer does not spend all his budget. He can jump on a higher indifference curve by increasing consumption of each good. Bundles A and C spend exhaust the budget. But C is not optimal. In absolute terms, the MRS is larger than the opportunity cost (price ratio) of consuming another unit of X. Therefore, she can increase X and reduce Y yielding higher utility. Point A is optimal: MRS is equal to the price ratio.

Todo

Play around with this animation at EconGraph.org

Direct approach

The problem is

• Maximize $$u(X,Y)$$ given the constraint $$p_X X+ p_YY = I$$

Step 1: Substitute the constraint

• If buys $$X$$ can consume $$Y(X) = \frac{I - p_X X}{p_Y}$$

• Utility now function of $$X$$ only: $$h(X) = u(X,Y(X))$$

Step 2: Maximize unconstrained

• Look at first order condition (FOC)

The FOC is:

$\frac{dh}{dX} = 0 \iff \frac{du}{dX} + \frac{dY}{dX}\frac{du}{dY} = 0$
$\iff \frac{du}{dX}\Bigg/\frac{du}{dY} = \frac{p_X}{p_Y}$

Important

At the optimum, the MRS is equal to the relative price. The willingness to pay to increase the quantity of one good, MRS coming from preferences, is equal to the opportunity cost, the relative price originating from the budget constraint.

Todo

Exercise D: Find demands for $$u(X,Y) = XY$$ under the constraint $$p_X X + p_Y Y \le I$$.

As an alternative, we can set up the Lagrangian:

$L(X,Y,\lambda) = u(X,Y) - \lambda (p_X X + p_Y Y - I)$

The constrained problem is therefore $$\max_{X,Y,\lambda} L(X,Y,\lambda)$$. The FOCs are

$\begin{split}u'_X(X,Y) - \lambda p_X = 0 \\ u'_Y(X,Y) - \lambda p_Y = 0 \\ p_X X + p_Y Y = I\end{split}$

Taking the ratio of the first two FOC (after sending price terms to rhs), we get:

\begin{split}\begin{aligned} \frac{u'_X(X,Y)}{u'_Y(X,Y)} = \frac{p_X}{p_Y} \\ p_X X + p_Y Y = I\end{aligned}\end{split}

Hence, MRS equal to price ratio and budget constraint met are the two conditions for an optimum.

Todo

Exercise E: Find demands for $$u(X,Y) = XY$$ using the Lagrangian.

Demand functions $$X^*(p_X,p_Y,I)$$ and $$Y^*(p_X,p_Y,I)$$ are called Marshallian demands (Alfred Marshall).

For a Cobb-Douglas utility function of the type $$u(X,Y)=X^{\alpha}Y^{1-\alpha}$$, we have marshallian demands $$X(p_X,p_Y,I) = \alpha \frac{I}{p_X}$$ and $$Y(p_X,p_Y,I) = (1-\alpha)\frac{I}{p_Y}$$. We can program those directly.

def x_d(p_x,p_y,I,alpha):
return alpha*I/p_x
def y_d(p_x,p_y,I,alpha):
return (1-alpha)*I/p_y

x_d(1,1,100,0.5)


What will the call to the function x_d() return?

## Indirect utility¶

Indirect utility $$v(p_X,p_Y,I)$$ is the maximum level of utility the consumer can reach with prices $$(p_X,p_Y)$$ and income $$I$$,

$v(p_X,p_Y,I) = \max_{X,Y} \{ u(X,Y) : p_X X + p_Y Y \le I\}.$

By definition,

$v(p_X,p_Y,I) = u(X^*(p_X,p_Y,I),Y^*(p_X,p_Y,I))$

It is a useful function that we will use often and it provides a shortcut to get utility the consumer will achieve under a particular budget constraint if he maximizes utility.

We can program an indirect utility function directly. In the case of the Cobb-Douglas, we have

$v(p_X,p_Y,I) = \alpha^{\alpha}(1-\alpha)^{1-\alpha} \frac{I}{p_X^{\alpha}p_Y^{1-\alpha}}$

and so we can program

def v(p_x,p_y,I,alpha):
base = (alpha**alpha) * ((1-alpha)**(1-alpha))
return base * I / ((p_x**alpha) * (p_y**(1-alpha)))


We can also use the russian puppet trick…

def u(x,y,alpha):
return (x**alpha) * (y**(1-alpha))

def v(p_x,p_y,I,alpha):
xstar = x_d(p_x,p_y,I,alpha)
ystar = y_d(p_x,p_y,I,alpha)
return u(xstar,ystar,alpha)


This has the advantage that the v function is much more general.

## Preferences¶

Several forms of utility functions are used in applications. These exercises allow you a walk in the park with these functions. Watch out for the relationship between demand and price and income.

Todo

Exercise F: Find marshallian demands for quasi-linear preferences $$u(X,Y) = \sqrt{X} + Y$$.

Todo

Exercise G: Find demand functions for cobb-douglas preferences $$u(X,Y) = X^{1/3}Y^{2/3}$$.

Todo

Exercise H: Find demand functions for leontief preferences $$u(X,Y) = \min(X,Y)$$.

## Consumer Demand Example¶

See this example in Python for a special utility function that is often used in practice: the CES (Constant Elasticity of Substitution) 