clear set mem 5g ******************************************************************************* *Define globals for directories and files ******************************************************************************* global path_main "H:\RCOptim\Results\Nevo delivery 12 CK\Nevo delivery 12 CK" global path_temp "e:\crknittel" global path_figures "$path_main\figures\" ******************************************************************************** use "$path_main\market power results\nevo_mkt_power_results_all.dta" sort optmethod stvalue merge optmethod stvalue using "$path_main\optimization resultsNevo optimization results.dta" ******************************************************************************* *Convergence ******************************************************************************* capture gen conv2=0 replace conv2=1 if optmethod==1 &exitinfo==1 replace conv2=1 if optmethod==1 &exitinfo==2 replace conv2=1 if optmethod==2 &exitinfo==1 replace conv2=1 if optmethod==3 &exitinfo<4000 replace conv2=1 if optmethod==4 &exitinfo==2 replace conv2=1 if optmethod==5 &exitinfo==2 replace conv2=1 if optmethod==5 &exitinfo==4 /**replace conv2=1 if optmethod==6 &exitinfo==1**/ /**replace conv2=1 if optmethod==7 &exitinfo==1**/ replace conv2=1 if optmethod==8 &exitinfo==1 replace conv2=1 if optmethod==9 &exitinfo==1 replace conv2=1 if optmethod==10 &exitinfo==1 ******************************************************************************* ******************************************************************************* *Identify products with market shares *corresponding to the four quartiles of the market share distribution ******************************************************************************* sort optmethod stvalue share_obs market product, stable global market_25=market in 639 global product_25=product in 639 global market_50=market in 1278 global product_50=product in 1278 global market_75=market in 1917 global product_75=product in 1917 global market_100=market in 2256 global product_100=product in 2256 gen flag_025 = (market==$market_25) *(product==$product_25) gen flag_050 = (market==$market_50) *(product==$product_50) gen flag_075 = (market==$market_75) *(product==$product_75) gen flag_100 = (market==$market_100)*(product==$product_100) table market product if flag_025 ==1, c(min share_obs) f(%8.4fc) table market product if flag_050 ==1, c(min share_obs) f(%8.4fc) table market product if flag_075 ==1, c(min share_obs) f(%8.4fc) table market product if flag_100 ==1, c(min share_obs) f(%8.4fc) ************************************************************************** egen fval_optmethod_min = min(fval), by(optmethod) gen fval_optmethod_min_flag = 0 replace fval_optmethod_min_flag = (fval-fval_optmethod_min)<=10^(-4) sum fval if fval_optmethod_min_flag ************************************************************************** egen hessians_min=rowmin(hessians_*) gen flag_30=(gradients1_norm_inf<=30)*(hessians_min>=0)*conv2 ************************************************************************** cd "$path_figures" ******************************************************************************* *Figure 26 - Nevo ******************************************************************************* global upp=0 qui sum elast_own, detail, if flag_025==1&conv2==1 qui return list global low_025=-50 qui sum elast_own, detail, if flag_050==1&conv2==1 qui return list global low_050=-2 qui sum elast_own, detail, if flag_075==1&conv2==1 qui return list global low_075=-6.3 qui sum elast_own, detail, if flag_100==1&conv2==1 qui return list global low_100=-1.5 global w_025=$low_025/15 global w_025=$low_050/15 global w_025=$low_075/15 global w_025=$low_100/15 #delimit ; histogram elast_own if flag_025==1 & conv2==1 & elast_own>=$low_025 & elast_own<$upp, title(25th Percentile) xtitle(Own-Price Elasticity) saving(nevo_25, replace) xlabel(,format(%9.3f)) freq; histogram elast_own if flag_050==1 & conv2==1 & elast_own>=$low_050 & elast_own<$upp, title(50th Percentile) xtitle(Own-Price Elasticity) saving(nevo_median, replace) xlabel(,format(%9.3f)) freq; histogram elast_own if flag_075==1 & conv2==1 & elast_own>=$low_075 & elast_own<$upp, title(75th Percentile) xtitle(Own-Price Elasticity) saving(nevo_75, replace) xlabel(,format(%9.3f)) freq; histogram elast_own if flag_100==1 & conv2==1 & elast_own>=$low_100 & elast_own<$upp, title(Maximum) xtitle(Own-Price Elasticity) saving(nevo_largest, replace) xlabel(,format(%9.3f)) freq; graph combine nevo_25.gph nevo_median.gph nevo_75.gph nevo_largest.gph; graph export Figure26.wmf,replace; #delimit cr egen own_stddev=sd(elast_own), by(product market conv2) egen own_stddev_best=sd(elast_own), by(product market conv2 fval_optmethod_min_flag) sum own_stddev elast_own, detail, if conv2==1 sum own_stddev_best elast_own, detail, if conv2==1&fval_optmethod_min_flag==1 ******************************************************************************* *Figure 27 - Nevo ******************************************************************************* qui sum fval, detail, if conv2==1&optmethod~=6 qui return list global fval_upp=r(p75) #delimit ; histogram fval if conv2==1 &fval<$fval_upp &product==1 &market==1, freq w(5) xtitle(GMM Objective Values); graph export Figure27.wmf ,replace; #delimit cr