Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stata code to reconstruct gravity equation with CEPII data

    Hi everybody,

    I am new here and also not very good with stata. For a project, I have to reconstruct the gravity equation constructed by Gudgin et al. (2017) to evaluate the effect of Brexit on trade flows. To do this I have downloaded data from CEPII. As in the paper by Gudgin et al. I have trimmed the data down to Britain's top 60 export markets using the code:
    Code:
     keep if iso3num_d==840| iso3num_d==276 |
    . The code is not complete because I have done this 60 times (iso3num being the variable that identifies a given country) but just so you get an idea of what I am doing. Then in order to construct the following regression: trade flows = constant + log(GDP_home) + log(GDP_dest) + log(GDP_home/POP_home) + log(GDP_dest/POP_dest) + UK_EU + EU_both + EU_home + EU_dest + FTA_both + NOR_EU + SWZ_EU

    Code:
    gen lgdp_o=ln(gdp_o)
    
    gen lgdp_d=ln(gdp_d)
    
    gen lgpdpop_o=ln(gdp_o/pop_o)
    
    gen lgpdpop_d=ln(gdp_d/pop_d)
    
    gen uk_eu=1 if iso3num_o==826 & eu_d==1
    replace uk_eu=0 if iso3num_o==826 & eu_d==0
    
    gen eu_both=1 if eu_d==1 & eu_o==1
    replace eu_both=0 if eu_d==0 | eu_o==0
    
    gen nor_eu=1 if iso3num_o==578 & eu_d==1
    replace nor_eu=0 if iso3num_o==578 & eu_d==0
    
    gen swz_eu=1 if iso3num_o==756 & eu_d==1
    replace swz_eu=0 if iso3num_o==756 & eu_d==0
    
    gen ltrade=ln(tradeflow_baci)
    
    egen countrypair=group(iso3num_o iso3num_d) 
    duplicates drop countrypair year, force
    xtset countrypair year 
    
    xtreg ltrade lgdp_o lgdp_d lgpdpop_o lgpdpop_d eu_o eu_d eu_both fta_wto uk_eu nor_eu swz_eu, fe 
    
    estimates store fixed
    after the code xtreg ... stata tells me that there are no observations

    I do not know what I did wrong and why I do not obtain a regression output. Could you help me find the error and tell me how I can reconstruct the equation? Thank you in advance.

    I hope all of this makes sense
Working...
X