.. _Cons: 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. .. figure:: /images/distribution_conso.jpeg :scale: 100 :align: center `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 :math:`x = (x_1, x_2,\cdots,x_n)`. - For any baskets :math:`A` and :math:`B`, preferences dictate which one is preferred. - Preferences are just like wish lists. They ignore prices and resources. - Preference relations are denoted :math:`\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 (:math:`A\succ B`) - prefers **always** B to A (:math:`B\succ A`) - is indifferent between A and B (:math:`A \sim B`) *Transitivity* Given three baskets A, B, C such that :math:`A\succ B`, :math:`B \succ C`, then if transitivity holds he also prefers A to C (:math:`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 :math:`A \succ B`. - Weaker version (:math:`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? .. code-block:: 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) .. seealso:: `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 :math:`X,Y`: - Starting from a basket :math:`(X_0,Y_0)`, find combinations of :math:`(X,Y)` such that the consumer is indifferent between :math:`(X,Y)` and :math:`(X_0,Y_0)` - In the plane (:math:`X,Y`), higher indifference curves indicate a preference. Proposition: If transitivity holds, indifference curves cannot cross. .. figure:: /images/indif.png :scale: 25% :align: center .. 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 :math:`(X_0, Y_0)`, MRS of :math:`X` in terms of :math:`Y`: Quantity of good :math:`Y` the consumer is willing to sacrifice to increase :math:`X` by one unit It is the marginal value the consumer puts on :math:`X` in terms of quantity of good :math:`Y`. It corresponds to the slope at :math:`(X_0,Y_0)`. **Convexity of indifference curves** If the quantity of :math:`X` increases, how does the MRS for :math:`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 :math:`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. :math:`u` represents these preferences if :math:`A \succ B \Rightarrow u(A) > u(B)` and :math:`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 :math:`f` is a strictly increasing transformation (function) and :math:`u` represents some preferences, then :math:`g(X) = f(u(X))` represents the same preferences. .. math:: 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: :math:`u(X,Y) = \log X + \log Y` and :math:`g(X,Y) = XY` represent the same preferences. .. todo:: **Exercise B**: Show that :math:`u` and :math:`g` in this example have the same preferences by finding the transformation :math:`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, :math:`X`, :math:`Y`. Preferences are represented by :math:`u(X,Y)` - e.g. :math:`u(X,Y) = \log X + \log Y` We can write a more general utility function as: .. code-block:: import numpy as np def u(x,y,alphas): return alphas[0]*np.log(x) + alphas[1]*np.log(y) u(1.0,1.0,[0.5,0.5]) What will the call to u() return? MRS of :math:`X`: - How much :math:`Y` should one sacrifice to gain :math:`X` - Formally: if we increase :math:`X` by :math:`\Delta X`, what is the change :math:`\Delta Y` which maintains indifference? Let's calculate the MRS of :math:`X`. We can use total differentiation: .. math:: \begin{aligned} du = \frac{\partial u}{\partial X}dX + \frac{\partial u}{\partial Y}dY\end{aligned} Set :math:`du = 0` so that utility is fixed. Then .. math:: \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: .. code-block:: import numpy as np def mu_x(x,y,alphas): return alphas[0]/x def mu_y(x,y,alphas): return alphas[1]/y And finally the MRS: .. code-block:: 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) :math:`I` - Two goods :math:`X`, :math:`Y`: Constraint: :math:`p_X X + p_Y Y \leq I`. This constraint determines what is available given :math:`I` and prices. Setting to equality, we can solve for :math:`Y` in terms of :math:`X`: :math:`Y = \frac{I - p_X X}{p_Y}` The relative price between :math:`X` et :math:`Y` holding the budget constant is: .. math:: \frac{dY}{dX} = -\frac{p_X}{p_Y} Buying a unit of :math:`X` implies a sacrifice of :math:`\frac{p_X}{p_Y}` units of :math:`Y`. It is the opportunity cost of :math:`X` in terms of :math:`Y`. .. figure:: /images/budget_cons.png :scale: 75 :align: center In the space :math:`(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 :math:`\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 :math:`p_Y = 1`. Then :math:`Y = I - p_X X`. :math:`p_X` is in terms of the quantity of :math:`Y` (numéraire) and idem pour :math:`I`. Only relative prices matter. .. todo:: **Exercice C**: Show that the budget constraint does not change if we multiply prices and income by :math:`\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. .. figure:: /images/choice_cons.png :scale: 75 :align: center 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 :math:`u(X,Y)` given the constraint :math:`p_X X+ p_YY = I` Step 1: Substitute the constraint - If buys :math:`X` can consume :math:`Y(X) = \frac{I - p_X X}{p_Y}` - Utility now function of :math:`X` only: :math:`h(X) = u(X,Y(X))` Step 2: Maximize unconstrained - Look at first order condition (FOC) The FOC is: .. math:: \frac{dh}{dX} = 0 \iff \frac{du}{dX} + \frac{dY}{dX}\frac{du}{dY} = 0 .. math:: \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 :math:`u(X,Y) = XY` under the constraint :math:`p_X X + p_Y Y \le I`. As an alternative, we can set up the Lagrangian: .. math:: L(X,Y,\lambda) = u(X,Y) - \lambda (p_X X + p_Y Y - I) The constrained problem is therefore :math:`\max_{X,Y,\lambda} L(X,Y,\lambda)`. The FOCs are .. math:: u'_X(X,Y) - \lambda p_X = 0 \\ u'_Y(X,Y) - \lambda p_Y = 0 \\ p_X X + p_Y Y = I Taking the ratio of the first two FOC (after sending price terms to rhs), we get: .. math:: \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} Hence, MRS equal to price ratio and budget constraint met are the two conditions for an optimum. .. todo:: **Exercise E**: Find demands for :math:`u(X,Y) = XY` using the Lagrangian. Demand functions :math:`X^*(p_X,p_Y,I)` and :math:`Y^*(p_X,p_Y,I)` are called Marshallian demands (`Alfred Marshall `_). For a Cobb-Douglas utility function of the type :math:`u(X,Y)=X^{\alpha}Y^{1-\alpha}`, we have marshallian demands :math:`X(p_X,p_Y,I) = \alpha \frac{I}{p_X}` and :math:`Y(p_X,p_Y,I) = (1-\alpha)\frac{I}{p_Y}`. We can program those directly. .. code-block:: 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 :math:`v(p_X,p_Y,I)` is the maximum level of utility the consumer can reach with prices :math:`(p_X,p_Y)` and income :math:`I`, .. math:: v(p_X,p_Y,I) = \max_{X,Y} \{ u(X,Y) : p_X X + p_Y Y \le I\}. By definition, .. math:: 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 .. math:: 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 .. code-block:: 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... .. code-block:: 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 :math:`u(X,Y) = \sqrt{X} + Y`. .. todo:: **Exercise G**: Find demand functions for *cobb-douglas* preferences :math:`u(X,Y) = X^{1/3}Y^{2/3}`. .. todo:: **Exercise H**: Find demand functions for *leontief* preferences :math:`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) |ImageLink|_ .. |ImageLink| image:: https://colab.research.google.com/assets/colab-badge.svg .. _ImageLink: https://colab.research.google.com/github/politeco/micro_en/blob/main/Consumers.ipynb