AGRODEPTechnicalNoteTN-05April2013Hands-ongravityestimationwithSTATAVersion2MariaCipollinaandLucaSalvaticiAGRODEPTechnicalNotesaredesignedtodocumentstate-of-the-arttoolsandmethods.TheyarecirculatedinordertohelpAGRODEPmembersaddresstechnicalissuesintheiruseofmodelsanddata.TheTechnicalNoteshavebeenreviewedbuthavenotbeensubjecttoaformalexternalpeerreviewviaIFPRI’sPublicationsReviewCommittee;anyopinionsexpressedarethoseoftheauthor(s)anddonotnecessarilyreflecttheopinionsofAGRODEPorofIFPRI.Hands-ongravityestimationwithSTATAInthisdocumentwegiveseveralexamplesofhands-onestimationtofamiliarizeyourselfwiththegravityequationmethodologicalchoiceshighlightedintheliteraturereview.ThisguideprovidesanillustrativedatasetwithalternativeStatacodespresentingthedifferentpossibleestimationstrategies.Part1describeshowestimationsarecarriedoutwithpaneldataandaredirectedtoshowtherelevanceofthemultilateralresistancetermaswellasthemodelingofthe(trade)policyvariables.InPart2,cross-sectionsestimationsshowtheimportanceofworkingwithdisaggregateddata.Finally,Part3showshowyoucansolvethe‘zero(tradeflows)problem’usingeitherHeckmanorPoissonestimators.Asyoureadthisguide,youwilluseSTATAtocarryoutestimationsdesignedtofamiliarizeyouwiththesoftwareand,moreimportantly,thegravitymodel.STATAisastatisticalsoftwareprogramandweassumethatyouhavearecentversionofSTATA(version11.2orlater).Theinstructionsinthisguidearequitedetailed.Ouraimistogivesufficientdetailtoenableanewuserofthissoftwaretofollowtheexamplesrelyingsolelyonthisguide.Ontheotherhand,theguideisstrictlyrelatedtotheliteraturereviewthathighlightsthemaintheoreticalandmethodologicalissuesillustratedintheregressions.DatafilesTherearetwoDatafiles:dataset_def.dta:itcontainsalltheessentialvariablesusedintheregressionsusingpaneldata(Part1).Thedatasetcoverstheperiodfrom1996to2006andincludes154developedanddevelopingcountries.us_agr.dta:itcontainsalltheessentialvariablesusedintheregressionsusingcross-sectiondata(Part2andPart3).Itreferstoyear2004USagriculturalimportsfrom226countries.DataaredisaggregatedatthemostdetailedlevelallowedbytheinternationalHarmonizedSystem(HS)classification(6digits)andinclude689products.Thevariablenamesarelargelyself-explanatoryandaredescribedwhenthelabelsarecreated:theirgenerationandconstructioncanthusbedirectlyinspected.ThedatasourcesaredescribedintheAppendix.DofilesTherearethreeDofiles:regressionsaggregateddata.do:itrunsregressionsusingpanel,aggregateddata(Part1).regressionsdisaggregateddata.do:itrunsregressionsusingcross-section,disaggregatedaswellasaggregateddata(Part2).regressionszeroestreatment.do:itrunsregressionsusingnon-linearestimators(HeckmanorPoisson)dealingwith‘zero’tradeflows(Part3).Part1:AggregateddataA.VariableGeneration.PartAbringsinthedataandgeneratesthevariablesusedintheanalysis:(a)Weusethedatafiledataset_defusedataset_def.dta(b)Wetakethelogsofallcontinuousvariablesincludedintheregressions:glimports=ln(imports)glgdp_o=ln(gdp_o)glgdp_d=ln(gdp_d)gldist=ln(distw)gltariff=ln(1+s_average)(c)Welabelthevariablestobeincludedinthetables.lavarlimports“Ln(Imports)”lavarcolony“Coloniallink”lavarcomlang_off“Commonlanguage”lavarcontig“Border”lavarldist“Ln(distance)”lavarlgdp_d“Ln(GDP_importer)”lavarlgdp_o“Ln(GDP_exporter)”lavarrta“RegionalTradeAgreement”lavarltariff“Ln(1+Tariff)”(d)Finally,wegeneratethedifferentfixedeffects.quitabimp,g(dimp)quitabexp,g(dexp)quitabpair,g(dpair)quitabyear,g(dyear)B.RegressionSpecificationsPartBrunspanelregressionswithaggregateddata,andthedummyRTA(i.e.,RegionalTradeAgreements)as(trade)policyvariable.Regressionsarebasedonequation(2)withtime,importer,exporterandcountry-pairfixedeffects.Westartbydeclaringdatatobepanel.tssetpairyearInordertoshowtheconsequencesofignoringthemultilateralresistanceterm,wefirstlyestimateequation(2)withoutfixedeffectseststo:reglimportslgdp_dlgdp_oldistcontigcolonycomlang_offrta,robustThen,weintroducethedifferenttypesoffixedeffects:eststo:reglimportslgdp_dlgdp_oldistcontigcolonycomlang_offrtadyear*,robusteststo:reglimportslgdp_dlgdp_oldistcontigcolonycomlang_offrtadimp*dexp*,robusteststo:reglimportslgdp_dlgdp_oldistcontigcolonycomlang_offrtadimp*dexp*dyear*,robusteststo:reglimportslgdp_dlgdp_oldistcontigcolonycomlang_offrtadpair*dyear*,robustThedummyforpaireffectsisequalto1forallobservationsoftradeoccurringbetweenagivenpairofcountries,forallpairs.Countrydummiesremovecross-section,butnottime-seriesbiases.Thelatterisaseriousshortcomingsinceomittedfactorsaffectingbilateraltradecostsoftenvaryovertime.Pairdummiescannotbeusedincross-sectiondatasincethenumberofdummieswouldbeequaltothenumberofobservations.Thecommand“esttab”createstheregressiontableinafileregressions1.docesttabusingregressions1.doc,title(aggregate-dummypolicy)sear2labelreplacertfb(2)star(*0.10**0.05***0.01)se(2)mtidrop(dexp*dimp*dyear*dpair*)TABLE:PanelresultswithdifferentfixedeffectsModel1and2reportthebaseregression.Column(1.1)reportsresultswithoutfixedeffects.Column(2.1)reportsresultswheretimedummiesareaddedtotheregression,toaccountforthechangingnatureofthere