首页 > 解决方案 > Marginsplot 如何从图中删除某些数据

问题描述

我在 Stata 中有一个边距图,上面的线条太多,无法很好地阅读图表。我想删除不是我的情节重点的数据。

例如,我的输出是marginsplot五行,每行代表一个种族:

但是,我只想显示两条线,代表两个种族群体(URM 和白人,国内)

现在我的代码是:

reg y x##i.race $controls
margins x, by (race)
marginsplot

标签: graphstata

解决方案


您可以通过选择您计算利润的比赛来做到这一点:

webuse nhanes2, clear
local cntrls "finalwgt iron"
reg bpsystol sex#race `cntrls'
margins sex if inlist(race,1,2)==1, by (race)
marginsplot 

coefplotdrop()选项可以提供一种替代方法。注:coefplot来自 SSC ssc install coefplot:.


推荐阅读