marginsrsexContrastsofpredictivemarginsNumberofobs3000ModelVCEOIMExpressionProutcomepredictdfchi2x0000Pchi2sex1166100000DeltamethodContraststderr95confintervalsexFemalevsMale0618291015171903209270915 ID: 885302
Download Pdf The PPT/PDF document "marginscontrast151Contrastsofmargins5" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
1 margins,contrastContrastsofmargins
margins,contrastContrastsofmargins5 .marginsr.sexContrastsofpredictivemarginsNumberofobs=3,000ModelVCE:OIMExpression:Pr(outcome),predict() dfchi2Pchi2 sex 116.610.0000 Delta-method Contraststd.err.[95%conf.interval] sex (FemalevsMale) .0618291.0151719.0320927.0915656 Ther.prexforsexisthereference-categorycontrastoperatorsee[R]contrast.(Thedefaultreferencecategoryiszero,thelowestvalueofsex.)Contrastoperatorsinamarginlistworkjustastheydointhetermlistofacontrastcommand.Thecontrastestimateof0.06saysthatunconditionalongroup,femalesonaverageareabout6%morelikelythanmalestohaveapositiveoutcome.The2statisticof16.61showsthatthecontrastissignicantlydifferentfromzero.Youmaybesurp
2 risedthatwedidnotneedtoincludethecontras
risedthatwedidnotneedtoincludethecontrastoptiontoestimateourcontrast.Ifwehadincludedtheoption,ouroutputwouldnothavechanged:.marginsr.sex,contrastContrastsofpredictivemarginsNumberofobs=3,000ModelVCE:OIMExpression:Pr(outcome),predict() dfchi2Pchi2 sex 116.610.0000 Delta-method Contraststd.err.[95%conf.interval] sex (FemalevsMale) .0618291.0151719.0320927.0915656 Thecontrastoptionisusefulmostlyforitssuboptions,whichcontroltheoutputandhowcontrastsareestimatedinmorecomplicatedsituations.Butcontrastmaybespeciedonitsown(withoutcontrastoperatorsorsuboptions)ifwedonotneedestimatesorcondenceintervals:.marginssexgroup,contrastContrastsofpredictivemarginsNumberofobs=3,000ModelVCE:OIMExpression:P
3 r(outcome),predict() dfchi2Pchi2
r(outcome),predict() dfchi2Pchi2 sex 116.610.0000 group 2225.760.0000 margins,contrastContrastsofmargins13 Example7:Regressionadjustmentwithabinarytreatmentvariablenlsw88.dtacontainswomen'swages(wage)indollarsperhour,abinaryvariableindicatingtheirunionstatus(union),yearsofexperience(ttl exp),andavariable,grade,indicatingthenumberofyearsofschoolingcompleted.Wewanttoknowhowbeinginaunion(thetreatment)affectswomen'swages.Traditionally,awageequationoftheformlnwagei=0+1unioni+2gradei+3ttl exp+4ttl exp2+iwouldbet.However,therearetwoshortcomingsthatwewillimproveupon.First,toavoidtheproblemofpredictingthelevelofalog-transformeddependentvariable,wewillusepoissonw
4 iththevce(robust)optiontotanexponent
iththevce(robust)optiontotanexponentialregressionmodel;seeWooldridge(2010,sec.18.2)forbackgroundonthisapproach.Second,thepreviousequationimpliesthatfactorsotherthanunionstatushavethesameimpactonwagesforbothunionandnonunionworkers.Regression-adjustmentestimatorsallowallthevariablestohavedifferentimpactsdependingonthelevelofthetreatmentvariable,andwecanaccomplishthathereusingfactor-variablenotation.InStata,wetourmodelbytyping.usehttps://www.stata-press.com/data/r17/nlsw88(NLSW,1988extract).poissonwagei.union##(c.gradec.ttl_exp##c.ttl_exp),vce(robust)note:youareresponsibleforinterpretationofnoncountdep.variable.Iteration0:logpseudolikelihood=-4770.7957Iteration1:logpseudolikelihood=-4770.7693Ite
5 ration2:logpseudolikelihood=-4770.7693Po
ration2:logpseudolikelihood=-4770.7693PoissonregressionNumberofobs=1,876Waldchi2(7)=1047.11Probchi2=0.0000Logpseudolikelihood=-4770.7693PseudoR2=0.1195 Robustwage Coefficientstd.err.zP|z|[95%conf.interval] union Union .8638376.1682335.130.000.5341071.193568grade .0895252.005687415.740.000.0783782.1006722ttl_exp .0805737.01145347.030.000.0581255.103022 c.ttl_exp# c.ttl_exp -.0015502.0004612-3.360.001-.0024541-.0006463 union# c.grade Union -.0310298.0088259-3.520.000-.0483282-.0137314 union# c.ttl_exp Union -.0404226.0230113-1.760.079-.085524.0046788 union# c.ttl_exp# c.ttl_exp Union .0011808.00084281.400.161-.0004711.0028327 _cons .017488.08936020.200.845-.1576547.1926308 14margins,con
6 trastContrastsofmargins Toseehowun
trastContrastsofmargins Toseehowunionstatusaffectswages,wecanusemargins:.marginsr.union,vce(unconditional)ContrastsofpredictivemarginsNumberofobs=1,876Expression:Predictednumberofevents,predict() dfchi2Pchi2 union 126.220.0000 Unconditional Contraststd.err.[95%conf.interval] union (UnionvsNonunion) 1.004119.1960944.61978151.388457 Theestimatedcontrast1.004indicatesthatonaverage,belongingtoaunioncausesawoman'swagetobeslightlymorethanadollarhigherthanifshewerenotintheunion.Thisestimatedcontrastiscalledtheaveragetreatmenteffect(ATE).Conceptually,wepredictedthewageofeachwomanintheestimationsampleassumingshewasinaunionandobtainedthesamplemean.Wethenpredictedeachwoman'swageassumingshewasnotin
7 aunionandobtainedthatsamplemean.Thediffe
aunionandobtainedthatsamplemean.ThedifferencebetweenthesetwosamplemeansrepresentstheATE.Weobtainessentiallythesameresultsbyusingteffectsra:.teffectsra(wagec.gradec.ttl_exp##c.ttl_exp,poisson)(union)Iteration0:EEcriterion=2.611e-13Iteration1:EEcriterion=1.112e-26Treatment-effectsestimationNumberofobs=1,876Estimator:regressionadjustmentOutcomemodel:PoissonTreatmentmodel:none Robustwage Coefficientstd.err.zP|z|[95%conf.interval] ATE union (Union vs Nonunion) 1.004119.19604215.120.000.6198841.388355 POmean union Nonunion 7.346493.109618267.020.0007.1316457.561341 ThepointestimatesoftheATEareidenticaltothoseweobtainedusingmargins,thoughthestandarderrorsdifferslightlyfromthosereportedbymargins.Thes
8 tandarderrorsfromthetwoestimatorsare,how
tandarderrorsfromthetwoestimatorsare,however,asymptoticallyequivalent,meaningtheywouldcoincidewithasufcientlylargedataset.Thelaststatisticinthisoutputtableindicatestheuntreatedpotential-outcomemean(untreatedPOM),whichisthemeanpredictedwageassumingeachwomandidnotbelongtoaunion.Ifwespecifythepomeansoptionwithteffectsra,wecanobtainboththetreatedandtheuntreatedPOMs,whichrepresentthepredictedmeanwagesassumingallwomenwereorwerenotintheunion: margins,contrastContrastsofmargins15 .teffectsra(wagec.gradec.ttl_exp##c.ttl_exp,poisson)(union),pomeansIteration0:EEcriterion=2.611e-13Iteration1:EEcriterion=1.112e-26Treatment-effectsestimationNumberofobs=1,876Estimator:regressionadjustmentOutcomemodel:Pois
9 sonTreatmentmodel:none Robustwage Coeffi
sonTreatmentmodel:none Robustwage Coefficientstd.err.zP|z|[95%conf.interval] POmeans union Nonunion 7.346493.109618267.020.0007.1316457.561341Union 8.350612.175734647.520.0008.0061798.695046 NoticethatthedifferencebetweenthesetwoPOMsequals1.004119,whichistheATEweobtainedearlier. Insomeapplications,theaveragetreatmenteffectofthetreated(ATET)ismoregermanethantheATE.Forexample,iftheuntreatedsubjectsinthesamplecouldnotpossiblyreceivetreatment(perhapsbecauseamedicalconditionprecludestheirtakinganexperimentaldrug),thenconsideringthecounterfactualoutcomehadthosesubjectstakenthedrugmaynotberelevant.Inthesecases,theATETisabetterstatisticbecauseitmeasurestheeffectofthetreatmentonlyforthosesubjectswhoac
10 tuallydidreceivetreatment.LiketheATE,the
tuallydidreceivetreatment.LiketheATE,theATETinvolvescomputingpredictedoutcomesforeachtreatmentlevel,obtainingthesamplemeans,andcomputingthedifferencebetweenthosetwomeans.UnliketheATE,however,weuseonlyobservationscorrespondingtotreatedsubjects. Example8:Regressionadjustmentwithabinarytreatmentvariable(continued)HerewecalculatetheATETofunionmembership,rstusingmargins.Becauseteffectsraoverwroteourestimationresults,werstquietlyretourpoissonmodel.WethencallmarginstoobtaintheATET:.quietlypoissonwagei.union##(c.gradec.ttl_exp##c.ttl_exp),vce(robust).marginsr.union,subpop(union)vce(unconditional)ContrastsofpredictivemarginsNumberofobs=1,876Subpop.no.obs=460Expression:Predictednumberofevents,predi
11 ct() dfchi2Pchi2 union 118.860.0
ct() dfchi2Pchi2 union 118.860.0000 Unconditional Contraststd.err.[95%conf.interval] union (UnionvsNonunion) .901419.2075863.49455741.308281 Thekeyherewasspecifyingthesubpop(union)optiontorestrictmargin'scomputationstothosewomenwhoareunionmembers.Theresultsindicatethatbeingintheunioncausestheunionmembers'wagestobeabout90centshigherthantheywouldotherwisebe. 16margins,contrastContrastsofmargins Toreplicatetheseresultsusingteffectsra,weincludetheatetoptiontoobtainATETs:.teffectsra(wagec.gradec.ttl_exp##c.ttl_exp,poisson)(union),atetIteration0:EEcriterion=2.611e-13Iteration1:EEcriterion=9.347e-27Treatment-effectsestimationNumberofobs=1,876Estimator:regressionadjustmentOutcomemodel:PoissonTr
12 eatmentmodel:none Robustwage Coefficient
eatmentmodel:none Robustwage Coefficientstd.err.zP|z|[95%conf.interval] ATET union (Union vs Nonunion) .901419.20753094.340.000.49466581.308172 POmean union Nonunion 7.776417.16212147.970.0007.4586658.094168 Weobtainthesamepointestimateoftheeffectofunionstatusaswithmargins.Asbefore,thestandarderrorsdifferslightlybetweenthetwoestimators,buttheyareasymptoticallyequivalent.Theoutputalsoindicatesthatamongthewomenwhoareinaunion,theiraveragewagewouldbe$7.78iftheywerenotinaunion. TechnicalnoteOneadvantageoftheATETovertheATEisthattheATETcanbeconsistentlyestimatedwithslightlyweakerassumptionsthanarerequiredtoconsistentlyestimatetheATE.SeeComparingtheATEandATETinRemarksandexamplesof[TE]teffectsintroadv
13 anced. Bothmarginsandteffectscanestimate
anced. Bothmarginsandteffectscanestimatetreatmenteffectsusingregressionadjustment,sowhichshouldyouuse?Inadditiontoregressionadjustment,theteffectscommandimplementsotherestimatorsoftreatmenteffects;someoftheseestimatorspossessdesirablerobustnesspropertiesthatwecannotreplicateusingmargins.Moreover,alltheteffectsestimatorsuseacommonsyntaxandautomaticallypresenttheestimatedtreatmenteffects,whereaswemustrsttourownregressionmodelandthencallmarginstoobtainthetreatmenteffects.Ontheotherhand,particularlywiththeat()option,marginsgivesusmoreexibilityinspecifyingourscenarios.Theteffectscommandsallowustomeasuretheeffectofasinglebinaryormultinomialtreatment,butwecanhavemarginscomputetheeffectsofarbitra
14 ryinterventions,asweillustrateinthenexte
ryinterventions,asweillustrateinthenextexample. Example9:InterventionsinvolvingmultiplevariablesSupposewewanttoseehowwomen'swageswouldbeaffectedifwecouldincreaseeachwoman'seducationlevelbyoneyear.Thatis,wewanttomeasurethetreatmenteffectofanadditionalyearofschooling.Weassumethatifawomanattainsanotheryearofschooling,shecannotsimultaneouslywork.Thus,anadditionalyearofeducationimplieshertotalworkexperiencemustdecreasebyayear.Theexibleat()optionofmarginsallowsustomanipulatebothvariablesatonce: margins,contrastContrastsofmargins17 .quietlypoissonwagei.union##(c.gradec.ttl_exp##c.ttl_exp),vce(robust).margins,at((asobserved)_all)at(grade=generate(grade+1)ttl_exp=generate(ttl_exp-1))
15 contrast(atcontrast(r._at))Contrastsofpr
contrast(atcontrast(r._at))ContrastsofpredictivemarginsNumberofobs=1,876ModelVCE:RobustExpression:Predictednumberofevents,predict()1._at:(asobserved)2._at:grade=grade+1ttl_exp=ttl_exp-1 dfchi2Pchi2 _at 158.530.0000 Delta-method Contraststd.err.[95%conf.interval] _at (2vs1) .3390392.0443161.2521813.4258971 Therstat()optioninstructsmarginstoobtainpredictedwagesforallwomeninthesampleusingtheirexistingvaluesforgradeandttl expandtorecordthemeanofthosepredictions.Thesecondat()optioninstructsmarginstoobtainthemeanpredictedwageunderthecounterfactualscenariowhereeachwoman'seducationlevelisincreasedbyoneyearandtotalworkexperienceissimultaneouslydecreasedbyoneyear.Thecontrast()optioninstructsmargins
16 tocomputethedifferencebetweenthetwomeans
tocomputethedifferencebetweenthetwomeans.Theoutputindicatesthatincreasingeducationbyoneyear,whichwillnecessarilydecreaseworkexperiencebythesameamount,willcausetheaveragewagetoincreasebyabout34centsperhour,astatisticallysignicantamount. Conclusionmargins,contrastisapowerfulcommand,anditsabundanceofsuboptionsmayseemdaunting.Thesuboptionsareintheserviceofonlythreegoals,however.Therearethreethingsthatmargins,contrastcandowithafactorvariableorasetofat()denitions:1.Performcontrastsacrossthelevelsofthefactororset(asinexample1).2.Performajointtestacrossthelevelsofthefactororset(asinexample5).3.Performothertestsandcontrastswithineachlevelofthefactororset(asinexample4).Thedefaultbehaviorforvariablesspe
17 ciedinsideat(),over(),andwithin()ist
ciedinsideat(),over(),andwithin()istoperformcontrastswithingroups;thedefaultbehaviorforvariablesinthemarginlististoperformjointtestsacrossgroups. 18margins,contrastContrastsofmargins Storedresultsmargins,contraststoresthefollowingadditionalresultsinr():Scalarsr(k terms)numberoftermsparticipatingincontrastsMacrosr(cmd)contrastr(cmd2)marginsr(overall)overalloremptyMatricesr(L)matrixofcontrastsappliedtothemarginsr(chi2)vectorof2statisticsr(p)vectorofp-valuescorrespondingtor(chi2)r(df)vectorofdegreesoffreedomcorrespondingtor(p)margins,contrastwiththepostoptionalsostoresthefollowingadditionalresultsine():Scalarse(k terms)numberoftermsparticipatingincontrastsMacrose(cmd)contraste(cmd2)margin
18 se(overall)overalloremptyMatricese(L)mat
se(overall)overalloremptyMatricese(L)matrixofcontrastsappliedtothemarginse(chi2)vectorof2statisticse(p)vectorofp-valuescorrespondingtoe(chi2)e(df)vectorofdegreesoffreedomcorrespondingtoe(p)MethodsandformulasSeeMethodsandformulasin[R]marginsandMethodsandformulasin[R]contrast.ReferenceWooldridge,J.M.2010.EconometricAnalysisofCrossSectionandPanelData.2nded.Cambridge,MA:MITPress.Alsosee[R]contrastContrastsandlinearhypothesistestsafterestimation[R]lincomLinearcombinationsofparameters[R]marginsMarginalmeans,predictivemargins,andmarginaleffects[R]marginspostestimationPostestimationtoolsformargins[R]margins,pwcomparePairwisecomparisonsofmargins[R]pwcomparePairwisecomp