clear all set more off version 11.1 clear all set mem 500m global points=2500 set obs $points // parameters global alpha=.3 // cobb douglas function parameter : (x^alpha)*(y^(1-alpha)) global budget=100 global p1=2 global p2=3 //calculations gen counter=_n gen y=(($budget/$p2)/$points)*counter gen x=($budget -$p2*y)/$p1 scalar x_sol=($budget*$alpha)/$p1 di x_sol global sol1=x_sol scalar y_sol=($budget-$p1*x_sol)/$p2 di y_sol global sol2=y_sol scalar utility=(x_sol^$alpha)*(y_sol^(1-$alpha)) di utility gen ux=x if (x>0.1*($budget/$p1))&(x<0.9*($budget/$p1)) // sum to find solution point gen uy= (utility^(1/(1-$alpha)))/(ux^($alpha/(1-$alpha))) twoway line y x || line uy ux ||, ytitle( "Cooperation") xtitle( "Conflict" )title( "Cobb-Douglas Utility Function, alpha = $alpha ",span ) subtitle("Equilibrium: Conflict=$sol1, Cooperation= $sol2") legend( label(1 "Budget Constraint") label(2 "Utility Function") ) note("Model Parameters: Budget=$budget, p1=$p1, p2=$p2") //format solution