Marginsplot how to remove certain data from graph

Viewed 218

I have a margins plot in Stata with too many lines on it to read the graph well. I want to remove the data that is not the focus of my plot.

For example, the output I have is this marginsplot with five lines, each representing a racial group:

However, I'd only like to display two lines, representing two racial groups (URM and White, Domestic)

Right now my code is:

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

You can do this by selecting the races for which you calculate the margins:

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

coefplot's drop() option could provide an alternative allows this. Note: coefplot is from SSC: ssc install coefplot.

Related