Consumer Optimization


Consumer optimization takes in a budget line and indifferent curves to determine the consumer’s optimal consumption bundle. KGJS offers several ways to combine these concepts to create graphs for consumer optimization.

Budget Lines

First, let’s look at how to create a budget line. Here is a simple example of a budget line:

schema: EconSchema layout: OneGraph: graph: xAxis: title: "Good 1" yAxis: title: "Good 2" objects: - EconBudgetLine: p1: 1 p2: 2 m: 8 label: {text: M, location: 0.9}

Here, p1 indicates the price of good 1 and p2 indicates the price of good 2. m is the endowment, or the amount of money that the agent has to spend on the two goods in total. The label is similar to other labels, but since the budget line is defined by a segment in the back-end code of KGJS, we define the ‘location’ of the label by its distance along the segment. Here, we use .9 to say that the label is 9/10ths of the way along the budget line from left-to-right. This is convenient when we drag budget lines, since the label will always be plaecd proportionally along the budget line rather than at a fixed x- or y-value.

Indifference Curves

Next, let’s take a look at indifference curves. KGJS includes several built-in indifference curves that are used in introductory economics, including:

Each of the above indifference curve types can take in possible parameters, as we will explore below.

Let’s begin with a simple Cobb Douglas indifference curve. Remember to use EconSchema when writing code with econ features so that the colors show up appropriately:

schema: EconSchema layout: OneGraph: graph: xAxis: title: "Good 1" yAxis: title: "Good 2" objects: - EconIndifferenceCurve: utilityFunction: CobbDouglas: {alpha: 0.3} level: 5

Note the following features of this indifference curve:

We can also write Cobb Douglas using coefficients, indicating the a and b values in the expression ((x_1)^a)*((x_2)^b).

schema: EconSchema layout: OneGraph: graph: xAxis: title: "Good 1" yAxis: title: "Good 2" objects: - EconIndifferenceCurve: utilityFunction: CobbDouglas: {coefficients: [1,2]} level: 10

Now, let’s look at a substitutes indifference curve:

schema: EconSchema layout: OneGraph: graph: xAxis: title: "Good 1" yAxis: title: "Good 2" objects: - EconIndifferenceCurve: utilityFunction: Substitutes: {coefficients: [1,2]} level: 10

Here, we use coefficients: [a,b] in the context of the utility function $a(x_1) + b(x_2)$, as in the equation for substitutes.

Now, here is a quasilinear function:

schema: EconSchema layout: OneGraph: graph: xAxis: title: "Good 1" yAxis: title: "Good 2" objects: - EconIndifferenceCurve: utilityFunction: Quasilinear: {alpha: 0.3} level: 5

As a final example, let’s look at a CES function. The CES function takes in coefficients and an additional parameter, r, as in the equation $((a(x_1)^r b(x_2)^r)^(1/r))$:

schema: EconSchema layout: OneGraph: graph: xAxis: title: "Good 1" yAxis: title: "Good 2" objects: - EconIndifferenceCurve: utilityFunction: CES: {coefficients: [2,1], r: .5} level: 5

For each type of indifference curve, ‘alpha’ and ‘coefficients’ takes on a different mathematical meaning. These are described here:

One fun feature of indifference curves is the ability to make an indifference curve displaying indifference curves at different levels of utility on the graph. Let’s take a look at a Cobb-Douglas example:

schema: EconSchema layout: OneGraph: graph: xAxis: title: "Good 1" yAxis: title: "Good 2" objects: - EconIndifferenceMap: utilityFunction: CobbDouglas: {alpha: .4} levels: [1,2,3,4,5]

Rather than specifying a single utility level, you can add as many utility levels as you like to the indifference map. By default, these lines will show up thin and light grey.

Finally, you can also define an indifference curve not by a level, but by a bundle that it passes through, as shown below:

THIS ISN’T WORKING

Optimal Bundles

The Econ Optimal Bundle can be generated from a budget line and an indifference curve function. The Econ Optimal Bundle takes in these two functions and determines the optimal point for a consumer, as shown below:

schema: EconSchema layout: OneGraph: graph: xAxis: title: "Good 1" yAxis: title: "Good 2" objects: - EconOptimalBundle: budgetLine: p1: 1 p2: 2 m: 10 utilityFunction: PerfectComplements: coefficients: [1,3]

Notice that Econ Optimal Bundle automatically creates droplines with labels for the optimal quantity of Good 1 and Good 2 and the point X*, as well as labelling the utility function and the budget line.

KGJS
KineticGraphs.org
Getting Started

About the Project

Authoring Sandbox

Graphs & Layouts

Layouts

Sidebars

Graphs

Trees

3D Graphs

Graph Objects

Styling Graph Objects

Points

Lines

Curves

Contours

Shapes and Areas

Segments and Arrows

Angles and Angle Markers

User Interactions

Parameters

Calculations

Dragging

Economics

Econ Schema

Supply and Demand

Consumer Optimization

Exchange