Replication Files for "Good Names Beget Favors: The Impact of Country Image on Trade Flows and Welfare" Authors: Pao-Li Chang, Tomoki Fujii, and Wei Jin Date: October 2021 How to cite this dataset: CHANG, Pao-Li; FUJII, Tomoki; Jin, Wei (2022): Replication files for ˇ°Good names beget favors: The impact of country image on trade flows and welfareˇ±. SMU Research Data Repository (RDR). Dataset. https://doi.org/10.25440/smu.20552716 Coding for this paper was done in MATLAB (R2018b) and Stata (SE 15.1), both run on the Windows 10 operating system. To replicate our results, please keep the file folder structure unchanged and follow the instruction below step by step. If there is any mistake or typo, feel free to contact Wei Jin (by email wei.jin.economics@gmail.com). Your feedback would be greatly appreciated by us. Step 0 The replication starts with the Stata data file "main01.dta" located in the file folder "00main_data", where we also store the BBC WSP survey data "main_PIPA_20052017.dta" described in Appendix A.1 in file folder "org_pipa_2017", the leaders' diplomatic visit data "visitdata.xlsx" described in Appendix A.9 in "leader_visit", and the machine-learning democracy index "MLindices.dta" described in Appendix A.8 in "MLDI". "main01.dta" includes the bilateral trade flows described in Appendix A.2, the bilateral trade cost proxy variables described in Appendix A.5, the tariff and non-tariff measures described in Appendix A.6, the militarized interstate disputes, wars, the military alliance, the political system, the geographic region, the development stage, and the genetic distance data described in Appendix A.7, and the GDP, value-added share, gross output, and population data described in Appendix A.10. Run "master01.do", "master02_d.do", and "master03_o.do" sequentially, to generate the main data set for this paper "master07.dta". "master01.do" first merges "main01.dta" with the BBC WSP survey data, the leaders' diplomatic visit data, and the machine-learning democracy index data. Then it creates the pseudo world in the counterfactual analysis as described in Appendix A.12, associated with the expenditure data described in Appendix A.11. At the same time, it also generates a data set "master05.dta" for years 2004-2017 and another data set "master02_pipa.dta" for years 1995-2017. Based on "master05.dta" with available country image data, "master02_d.do" constructs the jj'-based IVs whereas "master03_o.do" constructs the ii'-based IVs. Other large interim data set such as "main02.dta", "master02_pipa.dta", and "master04.dta" may also be used in later steps, so we keep them for the time being and will erase them to save memory in the end (we recommend keeping them if your computer memory is large enough; otherwise, you may counter errors if directly jumping to later steps). Step 1 Go to the file folder "01dynamic". First, run "master_dynamic.do" to construct the data set for dynamic panel regressions "master_dynamic_06.dta". "master_dynamic.do" merges "master02_pipa.dta" in "00main_data" with the tariff data for years 1995-2017 titled "main_TTA01.dta". Then, run "Table8.do" and "Table8_abtest.do" to generate Table 8 in paper; run "TableA7.do" and "TableA7_abtest.do" to generate Table A.7 in paper; run "TableA8.do" and "TableA8_abtest.do" to generate Table A.8 in paper; run "TableA9.do" and "TableA9_abtest.do" to generate Table A.9 in paper.1 Step 2 Go to the file folder "02pipa_survey_tables_figures" and run "master.do" by using "..\00main_data\org_pipa_2017\main_PIPA_20052017.dta" and "..\00main_data\main02.dta". Then you can obtain "Figure1.dta" for Figure 1 in paper ("Figure1.tex" is the file used in LaTeX.), "Figure2_FE_PS_NG.csv" for Figure 2 ("Figure2_FE_PS_NG.tex" in LaTeX), "Figure3_residual_ij.dta" for Figure 3 ("Figure3_residual_ij.tex" in LaTeX), "Table1_evaluated_o_year_list.dta" and "Table1_evaluating_d_year_list.dta" together for Table 1, and "Table2.xls" for Table 2 in paper. We re-scale the numbers in "Figure1.dta", "Figure2_FE_PS_NG.csv", and "Figure3_residual_ij.dta" to fit for the size of A4 paper for publication and then generate the three tex files accordingly. The details of interim procedures are available upon request. Step 3 Go to file folder "03static_regressions" for the static regressions where we use the main data set "..\00main_data\master07.dta". Then run "Table3.do" to generate Table 3 in paper; run "Table4.do" to generate Table 4 in paper; run "Table5.do" and "Table5_weakivtest.do" to generate Table 5 in paper; run "Table6.do" and "Table6_weakivtest.do" to generate Table 6 in paper; run "Table7.do" and "Table7_weakivtest.do" to generate Table 7 in paper.2 Step 4 Go to file folder "04BEC", where we conduct the sectoral study by BEC classification. "disaggBEC_main_TTA.dta" contains HS2002 4-digit sectoral trade and tariff data as described in Appendix A.2, A.4, and A.6. Run "Table9.do" to generate Table 9 in paper by merging "disaggBEC_main_TTA.dta" with "..\00main_data\master07.dta". Step 5 Go to file folder "05Rauch", where we conduct the sectoral study by Rauch classification. "disaggRauch_main_TTA.dta" contains SITC2 3-digit sectoral trade and tariff data as described in Appendix A.2, A.4, and A.6. Run "Table10.do" to generate Table 10 in paper by merging "disaggRauch_main_TTA.dta" with "..\00main_data\master07.dta". Step 6 Go to file folder "06intra_firm" for the intra-firm trade analysis. "AMNE_PS.dta" is the cleaned intra-firm trade data from the OECD AMNE as described in Appendix A.3. Run "Table11.do" to generate Table 11 and run "Table12.do" to generate Table 12 in paper by merging "AMNE_PS.dta" with "..\00main_data\master07.dta", respectively. Step 7 Go to file folder "07counterfactuals" for the trade and welfare effects in the counterfactual analysis. The file folder "00_xtabond" conducts the dynamic panel estimation by copying "..\..\01dynamic\master_dynamic_06.dta", prepares the changes in country image by copying "..\..\00main_data\org_pipa_2017\main_PIPA_20052017.dta", and cleans the data set for counterfactuals by copying "..\..\00main_data\master02_pipa.dta". "b_p_CI.dta" in folder "00_xtabond" stores the coefficient, standard error, and lower bound and upper bound of 95% confidence interval of PSijt on trade flow which will be used for counterfactuals. "02_bn_N" contains the information of surveyed sample size in the nine excel files. "main_pipaN.do" reads the excel files and then generates "g_pipaN.dta" which will be used for the 95% confidence intervals of the welfare and trade effects based on Bernoulli standard error described in paper. The following folders correspond to the cases in paper: "USA_2011_2007", "Bush_2011_2007", "USA_2011_2017", "CHN_2012_2013", "Diaoyu_2012_2013", "GBR_2014_2017", and "CAN_2010_2017", which are referred to as A1, A2, B, C1, C2, D, and E, respectively. In each of the seven folders, you can find three m files: "main_caD_AvW3_A.m" for solving counterfactual equations by iteration, "main_caD_AvW3_A_post.m" for collecting the results after iteration and preparing the welfare numbers, and "main_caD_AvW3_A_post_ctyO.m" for cleaning the trade effects and preparing the figure associated in each case. The file folders with suffixes "_bnm", "_ps", and "_gama" are used to generate confidence intervals for the general equilibrium effects of country image on welfare and trade flows. For example, "GBR_2014_2017_bnm" corresponds to the Brexit effects of errors from sampling of PSijt based on Bernoulli standard error whereas "GBR_2014_2017_ps" corresponds to the Brexit effects of errors from sampling of PS ijt based on conservative margin of error. "GBR_2014_2017_gama" provides errors from estimation of gamma. In each of the three file folders associated with each case, you can find three m files: "gama2.m" for solving counterfactual equations by iteration, "gama3.m" for collecting the results after iteration and calculating the welfare and trade effects, and "x4.m" for further preparing the 95% confidence intervals of welfare effects and trade effects. To conduct the counterfactual analysis, run "run01.do", "run02.m", and "run03.do" in this sequence. Further description of these three files is included in the code files accordingly. By running these codes, you can generate the following figures: Figure 6 in paper as "Figure6.png" in file folder "USA_2011_2007", Figure 7 in paper as "Figure7.png" in file folder "Bush_2011_2007", Figure 8 in paper as "Figure8.png" in file folder "USA_2011_2017", Figure 9 in paper as "Figure9.png" in file folder "CHN_2012_2013", Figure 10 in paper as "Figure10.png" in file folder "Diaoyu_2012_2013", Figure 11 in paper as "Figure11.png" in file folder "GBR_2014_2017", and Figure 12 in paper as "Figure12.png" in file folder "CAN_2010_2017". Then run "Table13.do" to generate Table 13 in paper by combining "..\00main_data\main01.dta" and "..\00main_data\master02_pipa.dta"; run "Table14.do" to generate Table 14 in paper after "run01.do" from data in the five folders: "USA_2011_2007", "USA_2011_2017", "CHN_2012_2013", "GBR_2014_2017", and "CAN_2010_2017", respectively; run "Table15.do" to generate Table 15 in paper after "main_CA_AvW.do" and "main_CA_AvW_ctyO.do" as indicated in "run03.do" for the seven folders: "USA_2011_2007", "Bush_2011_2007", "USA_2011_2017", "CHN_2012_2013", "Diaoyu_2012_2013", "GBR_2014_2017", and "CAN_2010_2017", respectively; run "Table16.do" to generate Table 16 in paper after "run01.do" from data in the two folders: "Bush_2011_2007" and "Diaoyu_2012_2013"; run "Table17.do" to generate Table 17 in paper; and run "Table18.do" to generate Table 18 in paper. "Table17.do" and "Table18.do" are the last to run since they are preparing the 95% confidence intervals of welfare effects and trade effects. The main algorithm "mrs_caD_2v_AvW.m" to conduct the exact hat algebra in the counterfactual analysis will be described in the last part. Step 8 Go to file folder "08Conley" for the robustness of IV estimations ?la Conley, Hansen, and Rossi (2012). Run "Figure4.do" to generate "Figure4a.png" and "Figure4b.png" for Figure 4 in paper. Run "Figure5.do" to generate "Figure5a.png", "Figure5b.png", "Figure5c.png", and "Figure5d.png" for Figure 5 in paper. Run "FigureD1.do" to generate "FigureD1a.png", "FigureD1b.png", "FigureD1c.png", "FigureD1d.png", "FigureD1e.png", and "FigureD1f.png" for Figure D1 in paper. All the do files use "..\00main_data\master07.dta" to run estimations. We used version 3.1.2. dated July 01, 2020 of "plausexog.ado" written by Damian Clarke (http://www.damianclarke.net/computation/index.html) with minor modification to change the labelling. This version only allows deviations by only one instrument as noted in footnote 21 of our paper. However, this issue can be easily remedied by changing the following two lines (lines 39 and 40) from: GRAPHOMega (numlist min=2 max=22) graphmu (numlist min=2 max=22) to the below: GRAPHOMega (namelist) graphmu (namelist) The modified ado file should be saved as "plausexog2.ado" and placed in the same folder as "Figure4.do", "Figure5.do", and "FigureD1.do". Step 9 Go to file folder "09AppendixA" for some tables in Appendix A. Run "TableA1.do" and Table A.1 in paper is stored in "TableA1.log" generated. "TableA1.do" uses "..\00main_data\master07.dta", "..\04BEC\disaggBEC_main_TTA.dta", "..\05Rauch\disaggRauch_main_TTA.dta", and "..\06intra_firm\AMNE_PS.dta". Then, run "TableA2.do" to generate Table A.2 in paper by using "..\00main_data\main02.dta"; run "TableA3.do" to generate Table A.3 in paper by using "..\00main_data\main02.dta"; run "TableA4.do" and "TableA4_weakivtest.do" to generate Table A.4 in paper; run "TableA5.do" to generate Table A.5 in paper; run "TableA6.do" and "TableA6_weakivtest.do" to generate Table A.6 in paper. Tables A.4-A.6 use the main data set "..\00main_data\master07.dta". See also footnote 2. Step 10 Go to file folder "10Gallup" for the leadership analysis using Gallup data. Since Gallup is proprietary data, we only disclose the partial data related to some countries in our study in "corr_gallup.dta". Then run "TableA10.do" to generate Table A.10 in paper by using "corr_gallup.dta" and "corr_pipa.dta" cleaned from "..\00main_data\org_pipa_2017\main_PIPA_20052017.dta". Step 11 Go to file folder "11cost_benefit" for the cost-benefit analysis using international aid data as described in Appendix A.13. Then run "TableA11.do" to generate Table A.11 in paper. "AidData_cost.dta" is the international aid data in constant 2011 US dollars. Data on aid are obtained from "AidData", a research lab at the William & Mary Global Research Institute. More details are provided in Appendix A.13. We use WDI data (two series: GDP (current US$) and GDP deflator (base year varies by country)) to calculate America and China's real GDP in constant 2011 US dollars from "WDI_realGDP.xlsx". Then pecuniary gain is obtained by using the welfare effect numbers in Table 15 and the real GDP data. Step 12 Go to file folder "12AppendixB" for tables in Appendix B by using the main data set "..\00main_data\master07.dta". Run "TableB1.do" and Table B.1 in paper is stored in "TableB1.log" generated. Run "TableB2.do" and Table B.2 in paper is stored in "TableB2.log" generated. Run "TableB3.do" to generate Table B.3 in paper; run "TableB4.do" and "TableB4_weakivtest.do" to generate Table B.4 in paper; run "TableB5.do" and "TableB5_weakivtest.do" to generate Table B.5 in paper; run "TableB6.do" and "TableB6_weakivtest.do" to generate Table B.6 in paper. See also footnote 2. Step 13 Go to file folder "13AppendixC" for tables in Appendix C by using the main data set "..\00main_data\master07.dta". Run "TableC1.do" to generate Table C.1 in paper; run "TableC2.do" and "TableC2_weakivtest.do" to generate Table C.2 in paper; run "TableC3.do" and "TableC3_weakivtest.do" to generate Table C.3 in paper; run "TableC4.do" and "TableC4_weakivtest.do" to generate Table C.4 in paper. See also footnote 2. Step 14 Run "erase_large_files.do" to erase some large and useless interim files to save computer memory. But then you may counter errors if running some files now in the middle. No worries, please go back to Step 0, and re-start. Notes on MATLAB algorithm When we conduct the counterfactuals, we solve the system of structural equations in terms of the exact hat algebra by iteration. The main algorithm "mrs_caD_2v_AvW.m" is stored in file folder "07counterfactuals". The details are as follows. 1st, we re-structure all the counterfactual equations in terms of (), i.e., the changes in wage and price index. 2nd, we start with an initial guess of (). 3rd, we get () using the structural equations in paper. 4th, we can obtain a new price vector () according to its definition. 5th, we can get a new vector () by market-clearing condition. 6th, we use the new vectors () to update all the endogenous variables above. 7th, we iterate the whole procedure aforementioned until () converge. The convergence tolerance is set as 1e-7 which is quite accurate and reliable. It is well known that the counterfactual equations are homogeneous of degree 0 in terms of (). Then, we choose to normalize the price vector () such that its mean is equal to one. Then we can get the trade and welfare effects in the counterfactuals. 1 We conduct the Arellano-Bond test in a separate do-file, because Stata cannot calculate AR tests with dropped variables while many country-year FEs are indeed dropped due to collinearity in our dynamic panel regressions. So, we first generate the main tables with "Table8.do", "TableA7.do", "TableA8.do", and "TableA9.do". Then we conduct the Arellano-Bond test by dropping the collinear country-year FEs with "Table8_abtest.do", "TableA7_abtest.do", "TableA8_abtest.do", and "TableA9_abtest.do" to explicitly show the set of variables dropped in our implementation. 2 "Table 5.do" includes IV PPML regressions which take a long time to converge. We chose to conduct the effective F-statistics (Montiel Olea and Pflueger, 2013) in a separate file, "Table 5_weakivtest.do". However, it is straightforward to integrate these two do files. The same comment applies to Tables 6 and 7 as well as similar tables produced in Steps 9, 12, and 13. --------------- ------------------------------------------------------------ --------------- ------------------------------------------------------------