******************************************************************************* *To accompany Knittel and Metaxoglou (2008) *Work in Progess. Please do not cite without Permisssion *Knittel : crknittel@ucdavis.edu *Metaxoglou : konstantinos.metaxoglou@bateswhite.com ******************************************************************************* clear set memo 10000m set more off capture log close ******************************************************************************* *Define globals for directories and files ******************************************************************************* global path_main "H:\RCOptim\Results\~Nevo delivery CK\~Nevo delivery CK" global path_temp "e:\crknittel" global path_in "$path_main" global path_out "$path_main" global file_in_optim "$path_in\Optimization results\Optimization results.dta" global file_optim_tmp "$path_temp\nevo_optim_results_tmp.dta" global file_in_mkt_power "$path_in\market power results\nevo_mkt_power_results_all.dta" global file_in_mkt_power_tmp "$path_temp\nevo_mkt_power_results_all_tmp.dta" global file_in_merger "$path_in\merger results\nevo_merger_results_all.dta" global file_in_merger_tmp "$path_temp\nevo_merger_results_all_tmp.dta" global file_nevo_analysis "$path_temp\nevo_analysis.dta" global file_nevo_analysis_final "$path_temp\nevo_analysis_final.dta" global path_tables "H:\RCOptim\Results\nevo_base\Tables" global path_figures "$path_main\figures\" global figure18 "$path_temp\figure18.dta" global local_minima "$path_temp\nevo_local minima.dta" ******************************************************************************* *Load market power results - Nevo ******************************************************************************* use "$file_in_mkt_power", clear capture rename brand product keep if optmethod~=6 sort optmethod stvalue market product save "$file_in_mkt_power_tmp", replace ******************************************************************************* *Load merger results - Nevo ******************************************************************************* use "$file_in_merger", clear keep if optmethod~=6 capture rename start stvalue capture rename brand product capture drop *chng sort optmethod stvalue market product save "$file_in_merger_tmp", replace ******************************************************************************* *Merge the optimization, convergence, market power and merger results - Nevo *Prepare a dataset to produce figures and tables ******************************************************************************* use "$file_in_optim", clear ******************************************************************************* *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 save "$file_optim_tmp", replace ******************************************************************************* sort optmethod stvalue merge optmethod stvalue using "$file_in_mkt_power_tmp" tab _merge keep if _merge==3 drop _merge sort optmethod stvalue market product merge optmethod stvalue market product using "$file_in_merger_tmp" tab _merge keep if _merge==3 drop _merge compress save "$file_nevo_analysis", replace use "$file_nevo_analysis", clear gen flag=0 ******************************************************************************* *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) ******************************************************************************* *Identify the results that correspond to the minimum value *of the objective function for each of the 10 optimization routines ******************************************************************************* sort optmethod fval stvalue, stable egen fval_rank=group(optmethod fval stvalue) egen fval_rank_min=min(fval_rank), by(optmethod) replace fval_rank=fval_rank-fval_rank_min+1 gen fval_optmethod_min_flag = 0 replace fval_optmethod_min_flag = 1 if fval_rank==1 sum fval if fval_optmethod_min_flag ******************************************************************************* *Identify the closest substitute for the products with market shares *corresponding to the four quartiles of the market share distribution ******************************************************************************* global elast_cross_all elast_cross1-elast_cross24 *the presence of missing values affects the max calculation forvalues i=1(1)24 { qui replace elast_cross`i'=0 if elast_cross`i'==. } ***********HARD CODED************ global cross025=13 global cross050=5 global cross075=13 global cross100=2 sum elast_cross$cross025 sum elast_cross$cross050 sum elast_cross$cross075 sum elast_cross$cross100 gen price_chng = price_post-price_pre compress sort optmethod stvalue market product save "$file_nevo_analysis_final",replace ******************************************************************************* use "$file_nevo_analysis_final",clear keep mean_CV conv2 optmethod stvalue fval market fval_optmethod_min_flag collapse (mean) mean_CV conv2 fval_optmethod_min_flag fval, by(optmethod stvalue) gen mean_CV_pop=mean_CV*260*365/100 sum mean_CV_pop, detail, if conv2==1 qui return list global low=r(p1) global upp=0 gen flag=(conv2==1)*(mean_CV_pop>$low)*(mean_CV_pop<$upp) save "$figure18",replace ******************************************************************************* use "$file_nevo_analysis_final",clear keep gradients1_norm_inf hessians_* conv2 optmethod stvalue fval collapse (max) gradients1_norm_inf hessians_* conv2 fval, by(optmethod stvalue) egen hessians_min=rowmin(hessians*) gen flag_30=(gradients1_norm_inf<=30)*(hessians_min>=0)*(fval<300)*conv2 keep if flag_30==1 gsort optmethod stvalue keep optmethod stvalue flag_30 conv2 compress save "$local_minima",replace cd "$path_figures" use "$file_nevo_analysis_final",clear ******************************************************************************* *Figure 3 - Nevo ******************************************************************************* qui sum fval, detail, if conv2==1 qui return list global fval_upp=r(p75) graph hbox fval, over(optmethod) ytitle(GMM Objective Function Value), if fval<$fval_upp&product==1&market==1&conv2==1 graph export Figure03.wmf ,replace ******************************************************************************* *Figure 4 - Nevo ******************************************************************************* qui sum fval, detail, if conv2==1 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 Figure04.wmf ,replace; #delimit cr ******************************************************************************* *Figure 8 - Nevo ******************************************************************************* global upp=0 qui sum elast_own, detail, if flag_025==1&conv2==1 &fval<$fval_upp qui return list global low_025=r(p5) qui sum elast_own, detail, if flag_050==1&conv2==1 &fval<$fval_upp qui return list global low_050=r(p5) qui sum elast_own, detail, if flag_075==1&conv2==1 &fval<$fval_upp qui return list global low_075=r(p5) qui sum elast_own, detail, if flag_100==1&conv2==1 &fval<$fval_upp qui return list global low_100=r(p5) 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 &fval<$fval_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 &fval<$fval_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 &fval<$fval_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 &fval<$fval_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 Figure08.wmf,replace; #delimit cr erase nevo_25.gph erase nevo_median.gph erase nevo_75.gph erase nevo_largest.gph 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 9 - Nevo ******************************************************************************** global upp=0 qui sum elast_own, detail, if flag_025==1&conv2==1 &fval<$fval_upp qui return list global low_025=r(p5) qui sum elast_own, detail, if flag_050==1&conv2==1 &fval<$fval_upp qui return list global low_050=r(p5) qui sum elast_own, detail, if flag_075==1&conv2==1 &fval<$fval_upp qui return list global low_075=r(p5) qui sum elast_own, detail, if flag_100==1&conv2==1 &fval<$fval_upp qui return list global low_100=r(p5) #delimit ; histogram elast_own if flag_025==1 & conv2==1 & elast_own>=$low_025 & elast_own<$upp & ~inlist(optmethod,3,5) &fval<$fval_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 & ~inlist(optmethod,3,5) &fval<$fval_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 & ~inlist(optmethod,3,5) &fval<$fval_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 & ~inlist(optmethod,3,5) &fval<$fval_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 Figure09.wmf,replace; #delimit cr erase nevo_25.gph erase nevo_median.gph erase nevo_75.gph erase nevo_largest.gph ******************************************************************************* *Figure 10 - Nevo ******************************************************************************* qui sum elast_own, detail, if conv2==1 qui return list global low=r(p25) global upp=0 replace flag=(fval_optmethod_min_flag)*(elast_own>$low)*(elast_own<$upp)*(fval<$fval_upp) #delimit; twoway (kdensity elast_own if optmethod==1 & flag==1) (kdensity elast_own, lpattern(tight_dot), if optmethod==2 & flag==1) (kdensity elast_own, lpattern(dash), if optmethod==3 & flag==1) (kdensity elast_own, lpattern(dot), if optmethod==4 & flag==1) (kdensity elast_own, lpattern(longdash), if optmethod==5 & flag==1) (kdensity elast_own, lpattern(longdash_dot), if optmethod==6 & flag==1) (kdensity elast_own, lpattern(dash_3dot), if optmethod==7 & flag==1) (kdensity elast_own, lpattern(dash_dot), if optmethod==8 & flag==1) (kdensity elast_own, lpattern(shortdash), if optmethod==9 & flag==1) (kdensity elast_own, lpattern(shortdash_dot), if optmethod==10 & flag==1), legend(lab(1 "Quasi-Newton 1") lab(2 "Simplex") lab(3 "SolvOpt") lab(4 "Conjugate Gradient") lab(5 "Quasi-Newton 2") lab(6 "JBES GA") lab(7 "Simulated Annealing") lab(8 "MADS") lab(9 "GPS") lab(10 "Matlab GA")) ytitle(Density) xtitle(Own-Price Elasticity); graph export Figure10.wmf,replace; #delimit cr ******************************************************************************* *Figure 12 - Nevo ******************************************************************************* global low =0 qui sum elast_cross$cross025, detail, if flag_025==1&conv2==1 &fval<$fval_upp qui return list global upp_025=r(p95) qui sum elast_cross$cross050, detail, if flag_050==1&conv2==1 &fval<$fval_upp qui return list global upp_050=r(p95) qui sum elast_cross$cross075, detail, if flag_075==1&conv2==1 &fval<$fval_upp qui return list global upp_075=r(p95) qui sum elast_cross$cross100, detail, if flag_100==1&conv2==1 &fval<$fval_upp qui return list global upp_100=r(p95) #delimit; histogram elast_cross$cross025 if flag_025==1 & conv2==1 & elast_cross$cross025>=$low & elast_cross$cross025<=$upp_025 &fval<$fval_upp, title(25th Percentile) xtitle(Cross-Price Elasticity for Closest Substitute) saving(nevo_cross_25, replace) xlabel(,format(%9.3f)) freq; histogram elast_cross$cross050 if flag_050==1 & conv2==1 & elast_cross$cross050>=$low & elast_cross$cross050<=$upp_050 &fval<$fval_upp, title(50th Percentile) xtitle(Cross-Price Elasticity Closest for Substitute) saving(nevo_cross_median, replace) xlabel(,format(%9.3f)) freq; histogram elast_cross$cross075 if flag_075==1 & conv2==1 & elast_cross$cross075>=$low & elast_cross$cross075<=$upp_075 &fval<$fval_upp, title(75th Percentile) xtitle(Cross-Price Elasticity for Closest Substitute) saving(nevo_cross_75, replace) xlabel(,format(%9.3f)) freq; histogram elast_cross$cross100 if flag_100==1 & conv2==1 & elast_cross$cross100>=$low & elast_cross$cross100<=$upp_100 &fval<$fval_upp, title(Maximum) xtitle(Cross-Price Elasticity for Closest Substitute) saving(nevo_cross_largest, replace) xlabel(,format(%9.3f)) freq; graph combine nevo_cross_25.gph nevo_cross_median.gph nevo_cross_75.gph nevo_cross_largest.gph; graph export Figure12.wmf,replace; #delimit cr erase nevo_cross_25.gph erase nevo_cross_median.gph erase nevo_cross_75.gph erase nevo_cross_largest.gph ******************************************************************************* *Figure 13 - Nevo ******************************************************************************* global low =0 qui sum elast_cross$cross025, detail, if flag_025==1&conv2==1 &fval<$fval_upp qui return list global upp_025=r(p95) qui sum elast_cross$cross050, detail, if flag_050==1&conv2==1 &fval<$fval_upp qui return list global upp_050=r(p95) qui sum elast_cross$cross075, detail, if flag_075==1&conv2==1 &fval<$fval_upp qui return list global upp_075=r(p95) qui sum elast_cross$cross100, detail, if flag_100==1&conv2==1 &fval<$fval_upp qui return list global upp_100=r(p95) #delimit; histogram elast_cross$cross025 if flag_025==1 & conv2==1 & elast_cross$cross025>=$low & elast_cross$cross025<=$upp_025 & ~inlist(optmethod,3,5) &fval<$fval_upp, title(25th Percentile) xtitle(Cross-Price Elasticity for Closest Substitute) saving(nevo_cross_25, replace) xlabel(,format(%9.3f)) freq; histogram elast_cross$cross050 if flag_050==1 & conv2==1 & elast_cross$cross050>=$low & elast_cross$cross050<=$upp_050 & ~inlist(optmethod,3,5) &fval<$fval_upp, title(50th Percentile) xtitle(Cross-Price Elasticity Closest for Substitute) saving(nevo_cross_median, replace) xlabel(,format(%9.3f)) freq; histogram elast_cross$cross075 if flag_075==1 & conv2==1 & elast_cross$cross075>=$low & elast_cross$cross075<=$upp_075 & ~inlist(optmethod,3,5) &fval<$fval_upp, title(75th Percentile) xtitle(Cross-Price Elasticity for Closest Substitute) saving(nevo_cross_75, replace) xlabel(,format(%9.3f)) freq; histogram elast_cross$cross100 if flag_100==1 & conv2==1 & elast_cross$cross100>=$low & elast_cross$cross100<=$upp_100 & ~inlist(optmethod,3,5) &fval<$fval_upp, title(Maximum) xtitle(Cross-Price Elasticity for Closest Substitute) saving(nevo_cross_largest, replace) xlabel(,format(%9.3f)) freq; graph combine nevo_cross_25.gph nevo_cross_median.gph nevo_cross_75.gph nevo_cross_largest.gph; graph export Figure13.wmf,replace; #delimit cr erase nevo_cross_25.gph erase nevo_cross_median.gph erase nevo_cross_75.gph erase nevo_cross_largest.gph ******************************************************************************* *Figure 14 - Nevo ******************************************************************************* global low = 0 global highest=5 qui sum elast_cross$highest if conv2==1, detail qui return list global upp = r(p75) replace flag=(elast_cross$highest>$low)*(elast_cross$highest<$upp)*(fval_optmethod_min_flag==1)*(fval<$fval_upp) #delimit; twoway (kdensity elast_cross$highest if optmethod==1 & flag==1) (kdensity elast_cross$highest, lpattern(tight_dot), if optmethod==2 & flag==1) (kdensity elast_cross$highest, lpattern(dash), if optmethod==3 & flag==1) (kdensity elast_cross$highest, lpattern(dot), if optmethod==4 & flag==1) (kdensity elast_cross$highest, lpattern(longdash), if optmethod==5 & flag==1) (kdensity elast_cross$highest, lpattern(longdash_dot), if optmethod==6 & flag==1) (kdensity elast_cross$highest, lpattern(dash_3dot), if optmethod==7 & flag==1) (kdensity elast_cross$highest, lpattern(dash_dot), if optmethod==8 & flag==1) (kdensity elast_cross$highest, lpattern(shortdash), if optmethod==9 & flag==1) (kdensity elast_cross$highest, lpattern(shortdash_dot), if optmethod==10 & flag==1), legend(lab(1 "Quasi-Newton 1") lab(2 "Simplex") lab(3 "SolvOpt") lab(4 "Conjugate Gradient") lab(5 "Quasi-Newton 2") lab(6 "JBES GA") lab(7 "Simulated Annealing") lab(8 "MADS") lab(9 "GPS") lab(10 "Matlab GA")) ytitle(Density) xtitle(Cross-Price Elaticities for Product with Highest Average Cross-Price Elasticity); graph export Figure14.wmf, replace; #delimit cr ******************************************************************************* *Figure 15 - Nevo ******************************************************************************* qui sum elast_cross$highest, detail, if conv2==1 qui return list global low=0 global upp=r(p75)/2 replace flag=(elast_cross$highest>$low)*(elast_cross$highest<$upp)*(fval_optmethod_min_flag==1)*(fval<$fval_upp) #delimit; twoway (kdensity elast_cross$highest if optmethod==1 & flag==1) (kdensity elast_cross$highest, lpattern(tight_dot), if optmethod==2 & flag==1) (kdensity elast_cross$highest, lpattern(dash), if optmethod==3 & flag==1) (kdensity elast_cross$highest, lpattern(dot), if optmethod==4 & flag==1) (kdensity elast_cross$highest, lpattern(longdash), if optmethod==5 & flag==1) (kdensity elast_cross$highest, lpattern(longdash_dot), if optmethod==6 & flag==1) (kdensity elast_cross$highest, lpattern(dash_3dot), if optmethod==7 & flag==1) (kdensity elast_cross$highest, lpattern(dash_dot), if optmethod==8 & flag==1) (kdensity elast_cross$highest, lpattern(shortdash), if optmethod==9 & flag==1) (kdensity elast_cross$highest, lpattern(shortdash_dot), if optmethod==10 & flag==1), legend(lab(1 "Quasi-Newton 1") lab(2 "Simplex") lab(3 "SolvOpt") lab(4 "Conjugate Gradient") lab(5 "Quasi-Newton 2") lab(6 "JBES GA") lab(7 "Simulated Annealing") lab(8 "MADS") lab(9 "GPS") lab(10 "Matlab GA")) ytitle(Density) xtitle(Cross-Price Elaticities for Product with Highest Average Cross-Price Elasticity); graph export Figure15.wmf,replace; #delimit cr ******************************************************************************* *Figure 16 - Nevo ******************************************************************************* qui sum elast_cross$highest, detail, if conv2==1 qui return list global low=r(p75)/2 global upp=r(p75) replace flag=(elast_cross$highest>$low)*(elast_cross$highest<$upp)*(fval_optmethod_min_flag==1)*(fval<$fval_upp) #delimit; twoway (kdensity elast_cross$highest if optmethod==1 & flag==1) (kdensity elast_cross$highest, lpattern(tight_dot), if optmethod==2 & flag==1) (kdensity elast_cross$highest, lpattern(dash), if optmethod==3 & flag==1) (kdensity elast_cross$highest, lpattern(dot), if optmethod==4 & flag==1) (kdensity elast_cross$highest, lpattern(longdash), if optmethod==5 & flag==1) (kdensity elast_cross$highest, lpattern(longdash_dot), if optmethod==6 & flag==1) (kdensity elast_cross$highest, lpattern(dash_3dot), if optmethod==7 & flag==1) (kdensity elast_cross$highest, lpattern(dash_dot), if optmethod==8 & flag==1) (kdensity elast_cross$highest, lpattern(shortdash), if optmethod==9 & flag==1) (kdensity elast_cross$highest, lpattern(shortdash_dot), if optmethod==10 & flag==1), legend(lab(1 "Quasi-Newton 1") lab(2 "Simplex") lab(3 "SolvOpt") lab(4 "Conjugate Gradient") lab(5 "Quasi-Newton 2") lab(6 "JBES GA") lab(7 "Simulated Annealing") lab(8 "MADS") lab(9 "GPS") lab(10 "Matlab GA")) ytitle(Density) xtitle(Cross-Price Elaticities for Product with Highest Average Cross-Price Elasticity); graph export Figure16.wmf,replace; #delimit cr ******************************************************************************* * Figure 18 - Nevo ******************************************************************************* egen price_chng_stddev=sd(elast_own), by(product market conv2) egen price_chng_stddev_best=sd(elast_own), by(product market conv2 fval_optmethod_min_flag) sum price_chng_stddev price_chng, detail, if conv2==1 sum price_chng_stddev_best price_chng, detail, if conv2==1&fval_optmethod_min_flag==1 use "$figure18", clear histogram mean_CV_pop if flag==1 &fval<$fval_upp, w(.75) xtitle("Change in Consumer Welfare (millions of dollars)") freq graph export Figure18.wmf,replace ******************************************************************************* * Figure 19 - Nevo ******************************************************************************* use "$figure18", clear histogram mean_CV_pop if flag==1 &fval<$fval_upp & ~inlist(optmethod,3,5), w(.75) xtitle("Change in Consumer Welfare (millions of dollars)") freq graph export Figure19.wmf,replace ******************************************************************************* *Figure 22 - Nevo ******************************************************************************* use "$file_nevo_analysis_final", clear keep optmethod stvalue elast_own fval product market sort fval optmethod stvalue, stable global fval_drop=fval in 1 drop if fval==$fval_drop sort optmethod stvalue merge optmethod stvalue using "$local_minima" tab _merge keep if _merge==3 drop _merge drop if flag_30==0 global upp=0 global low=-10 #delimit; twoway (kdensity elast_own if optmethod== 1 &stvalue== 3 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 4 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 8 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 10 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 11 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 14 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 16 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 17 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 18 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 24 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 27 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 31 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 32 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 36 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 38 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 42 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 45 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 1 &stvalue== 47 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 4 &stvalue== 5 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 4 &stvalue== 6 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 4 &stvalue== 8 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 4 &stvalue== 14 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 4 &stvalue== 24 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 4 &stvalue== 36 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 4 &stvalue== 40 & elast_own>$low & elast_own<$upp ) (kdensity elast_own if optmethod== 4 &stvalue== 45 & elast_own>$low & elast_own<$upp ) , legend(off) ytitle(Density) xtitle(Own-Price Elasticity); graph export Figure22.wmf,replace; #delimit cr ******************************************************************************* * Figure 23 - Nevo ******************************************************************************* use "$figure18", clear sort fval optmethod stvalue, stable global fval_drop=fval in 1 drop if fval==$fval_drop sort optmethod stvalue merge optmethod stvalue using "$local_minima" tab _merge keep if _merge==3 drop _merge drop if flag_30==0 table stvalue optmethod histogram mean_CV_pop if flag==1 , w(.4) xtitle("Change in Consumer Welfare (millions of dollars)") freq graph export Figure23.wmf,replace ******************************************************************************* *Table 2 BLP parameter estimates for the best of the best ******************************************************************************* use "$file_nevo_analysis_final",clear #delimit ; browse optmethod fval price_mean const_sigma price_sigma sugar_sigma mushy_sigma const_inc_sigma price_inc_sigma sugar_inc_sigma mushy_inc_sigma price_inc2_sigma const_age_sigma sugar_age_sigma mushy_age_sigma price_child_sigma price_mean_se const_sigma_se price_sigma_se sugar_sigma_se mushy_sigma_se const_inc_sigma_se price_inc_sigma_se sugar_inc_sigma_se mushy_inc_sigma_se price_inc2_sigma_se const_age_sigma_se sugar_age_sigma_se mushy_age_sigma_se price_child_sigma_se if fval_optmethod_min_flag==1 &product==1 &market==1; #delimit cr ******************************************************************************* *Table 4 Nevo ******************************************************************************* use "$file_nevo_analysis_final",clear cd "$path_tables" foreach i in 025 050 075 100 { use "$file_nevo_analysis_final",clear drop if flag_`i'~=1 drop if conv2~=1 drop if fval>$fval_upp collapse (min) min_elast=elast_own (max) max_elast=elast_own, by(optmethod) outsheet using nevo_`i'_elast.csv, comma replace use "$file_nevo_analysis_final",clear drop if flag_`i'~=1 drop if conv2~=1 drop if fval_optmethod_min_flag~=1 drop if fval>$fval_upp collapse (min) min_elast=elast_own (max) max_elast=elast_own, by(optmethod) outsheet using nevo_`i'_best_elast.csv, comma replace } ******************************************************************************* *Table 6 Nevo ******************************************************************************* use "$file_nevo_analysis_final",clear drop if flag_025~=1 drop if conv2~=1 drop if fval>$fval_upp collapse (min) min_cross=elast_cross$cross025 (max) max_cross=elast_cross$cross025, by(optmethod) outsheet using nevo_025_cross_elast.csv, comma replace use "$file_nevo_analysis_final",clear drop if flag_025~=1 drop if conv2~=1 drop if fval_optmethod_min_flag~=1 drop if fval>$fval_upp collapse (min) min_cross=elast_cross$cross025 (max) max_cross=elast_cross$cross025, by(optmethod) outsheet using nevo_025_best_cross_elast.csv, comma replace use "$file_nevo_analysis_final",clear drop if flag_050~=1 drop if conv2~=1 drop if fval>$fval_upp collapse (min) min_cross=elast_cross$cross050 (max) max_cross=elast_cross$cross050, by(optmethod) outsheet using nevo_050_cross_elast.csv, comma replace use "$file_nevo_analysis_final",clear drop if flag_050~=1 drop if conv2~=1 drop if fval_optmethod_min_flag~=1 drop if fval>$fval_upp collapse (min) min_cross=elast_cross$cross050 (max) max_cross=elast_cross$cross050, by(optmethod) outsheet using nevo_050_best_cross_elast.csv, comma replace use "$file_nevo_analysis_final",clear drop if flag_075~=1 drop if conv2~=1 drop if fval>$fval_upp collapse (min) min_cross=elast_cross$cross075 (max) max_cross=elast_cross$cross075, by(optmethod) outsheet using nevo_075_cross_elast.csv, comma replace use "$file_nevo_analysis_final",clear drop if flag_075~=1 drop if conv2~=1 drop if fval_optmethod_min_flag~=1 drop if fval>$fval_upp collapse (min) min_cross=elast_cross$cross075 (max) max_cross=elast_cross$cross075, by(optmethod) outsheet using nevo_075_best_cross_elast.csv, comma replace use "$file_nevo_analysis_final",clear drop if flag_100~=1 drop if conv2~=1 drop if fval>$fval_upp collapse (min) min_cross=elast_cross$cross100 (max) max_cross=elast_cross$cross100, by(optmethod) outsheet using nevo_100_cross_elast.csv, comma replace use "$file_nevo_analysis_final",clear drop if flag_100~=1 drop if conv2~=1 drop if fval_optmethod_min_flag~=1 drop if fval>$fval_upp collapse (min) min_cross=elast_cross$cross100 (max) max_cross=elast_cross$cross100, by(optmethod) outsheet using nevo_100_best_cross_elast.csv, comma replace ******************************************************************************* *Generating standard deviation of cross-price estimates ******************************************************************************* use "$file_nevo_analysis_final", clear drop if conv2==0 forvalues i=1(1)24 { qui replace elast_cross`i'=. if elast_cross`i'==0 } stack elast_cross1 - elast_cross24, into(elast_cross_stack) clear sum elast_cross_stack, detail, if elast_cross_stack~=. use "$file_nevo_analysis_final", clear drop if conv2==0 forvalues i=1(1)24 { qui replace elast_cross`i'=. if elast_cross`i'==0 egen elast_cross`i'_stdev=sd(elast_cross`i'), by(product market) } stack elast_cross1_stdev - elast_cross24_stdev, into(elast_cross_stdev_stack) clear sum elast_cross_stdev_stack, detail, if elast_cross_stdev_stack~=. use "$file_nevo_analysis_final", clear drop if conv2==0 drop if fval_optmethod_min_flag==0 forvalues i=1(1)24 { qui replace elast_cross`i'=. if elast_cross`i'==0 } stack elast_cross1 - elast_cross24, into(elast_cross_best_stack) clear sum elast_cross_best_stack, detail, if elast_cross_best_stack~=. use "$file_nevo_analysis_final", clear drop if fval_optmethod_min_flag==0 forvalues i=1(1)24 { egen elast_cross`i'_stdev_best=sd(elast_cross`i'), by(product market conv2 fval_optmethod_min_flag) } stack elast_cross1_stdev_best - elast_cross24_stdev_best if conv2==1&fval_optmethod_min_flag==1, into(elast_cross_stdev_best_stack) sum elast_cross_stdev_best_stack, detail