8/3/2020

Utility Functions

In Economics, it is common to have to maximize utility functions subject to some budget constraint, and find the optimal consumption basket.

With the traditional chalkboard, it is somewhat hard to convey the idea of what happens when prices or income changes.

The idea with this shiny app is to make it more interactive to students to see what happens to optimal consumption baskets when parameters change.

Setting the app

To see how an optimal utility basket plot looks, let’s create some data using a simple cobb douglas function:

x <- 1:200
y <- 2500/x
plot(x, y, col = "blue", type = "l", xlim = c(0, 200), 
     ylim = c(0, 200), lwd = 2)
points(50, 50, cex = 2, pch = 19)
lines(x, 100 - x, col = "red", lwd = 2)

Justifying the APP

Having to plot many times in the chalkboard several plots is inconvenient, for sometimes they are not symetrical, and you cannot see slowly how the plot changes as the parameter change.

A shiny app can simulate the numbers of several functions, plot them, and allow the user to manipulate the parameters to look at changes in the optimal consumption basket right at the moment.

Shiny App Interface

The interface is really straight forward, with a side panel to change the parameters, and a main panel with the plot sensible to changes in the parameters.

The interface has a side panel to control the function parameters, such as the preference weight and the elasticity of substitution.

The side panel can also control the prices and income for the budget constraint.

Click here to go the the app