- Code a "package" to solve for Marshallian demand.
- Write a file
ConsumerFOC.oxh
file that declares the functionsMRS(),CES(),budget(),ConsumerFOC()
and the global variables that they use. (The header file should also include the standard library and import the maximize and solvenle packages.) - Define the functions in
ConsumerFOC.ox
using the specifications above. - Write a a main program to test and use the function. It would look like:
#import "ConsumerFOC" main() { // initialize the global parameters (given separately) // call SolveNLE() // print out the demand vector and the indirect utility. }
- Write a file
- Write an Ox program with:
- Two utilities as functions.
- Two 2x1 endowment vectors
- A function that takes an allocation $x^A$ and returns a vector of MRS values at the point in the Edgeworth Box.
- Generalize
- Create a graph of the Edgeworth Box using graphics in Ox.
- Use Ox numerical tools to solve for Pareto allocations
- Use numerical tools to solve for competitive equilibrium.
- Generalize to $M$ goods.
- Start with this blank program.
nash0.ox
- Write an Ox function that:
- Takes arguments pay-offs of a 2 person, 2 strategy game
- Computes each player's best response
- Finds and reports fixed points in the best response function (Nash Equilibria)
- Generalize
- Use labels for players and strategies to print out payoff matrices
- Generalize to $M$ strategies
- Generalize to $N$ players and $M_i$ strategies ($i=1,\dots,N$).
- Let $w\sim N(0,1)$ be a standard normal random variable. Let $EW^\star \equiv E[w | w\gt w^\star] = \int_{w^\star}^\infty w{\phi(w)\over 1-\Phi(w)}dw$ be the "truncated" mean of the random variable above the value $w^\star.$ Set $w^\star = 1.0$ (but also compute for larger and smaller values such as $w^\star=-4$ and $w^\star=5.$ Compute $EW^\star$ three different ways:
- Closed Form (IMR): the Inverse Mill's Ratio. Simplifying the general form to the standard normal case we get $EW^\star = {\phi(w^\star)\over 1-\Phi(w^\star)}.$ Recall that
densn()
andprobn()
are the Ox functions that return the normal density and cdf, respectively. - Gaussian Quadrature (GQ): Use the QuadPack routine demonstrated in class to compute a one tail integral. So simply write a function that returns the integrand in $EW^\star$ and let the quadrature do the rest.
- Monte Carlo Integration (MCI): draw $R$ pseudo-random values of $w.$ Then compute the (simple) average of values that are above $w^\star.$ Recall that
rann()
is Ox's standard normal pseudo random number function.
- Closed Form (IMR): the Inverse Mill's Ratio. Simplifying the general form to the standard normal case we get $EW^\star = {\phi(w^\star)\over 1-\Phi(w^\star)}.$ Recall that
- Once code for computing $EW^\star$ works for all the approaches, embed them in a function of the form required by
Num1Derivative()
. That is, re-think the calculation as $EW^\star \equiv EW(w^\star),$ the truncated mean as a function on the lower bound / reservation wage. Now you can useNum1Derivative()
to compute ${dEW(w^\star)\over dw^\star}.$ Print out the derivatives each method computes and note their accuracy.
Suggestion 1: Use a global variable to determine which method to use so you simply write one function not three:#include "oxstd.h" #import "maximize" decl method; //0=IMR, 1=GQ, 2=MC EWstar(wstar,aEW,G,H) //compute EW* in the form required by Num1Derivative
Suggestion 2: InsideEWstar()
you can useif () else if () else
to selection which method to compute, or learn to use Ox'sswitch_single()
statement:switch_single(method) { case 0: // put IMR code here case 1: // put GQ code here case 2: // put MC code here }
Suggestion 3: use a loop insidemain()
over methods:for(method=0;method<3;++method) { //sets the global variable used in EWstar wstar = 1.0; Num1Derivative(EWstar,&wstar,&dEW); println("method: ",method," dEW/dw*: ",dEW); }