Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: running marginsplots without rerunning margins again


From   Richard Williams <richardwilliams.ndu@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: running marginsplots without rerunning margins again
Date   Thu, 11 Aug 2011 11:16:03 -0400

At 10:39 AM 8/11/2011, Scott Merryman wrote:
There is an easier way.

-margins- has an undocumented saving() option

clear*
webuse nhanes2
regress bpsystol agegrp##sex if region ==4
margins agegrp, saving(mymargins,replace)
clear*
use mymargins
l
line _mar _m1,  lc(black)  ///
  || rcap _ci_u _ci_l _m1, lc(black) ///
  ||, legend(off)  xlabel(, valuelabel) ytitle(Linear Prediction)

Interesting. You aren't using marginsplot, but I guess you have the whole arsenal of graphics commands at your disposal.

With a little tweaking, this also works with Stata 11.2. You just substitute agegrp for _m1.

version 11.2
clear*
webuse nhanes2
regress bpsystol agegrp##sex if region ==4
margins agegrp, saving(mymargins,replace)
clear*
use mymargins
l
line _mar agegrp,  lc(black)  ///
  || rcap _ci_u _ci_l agegrp, lc(black) ///
  ||, legend(off)  xlabel(, valuelabel) ytitle(Linear Prediction)

Run that same code under Stata 12, though, and you get an error, i.e. it doesn't seem to respect the version control. So, this may be a use at your own risk, i.e. the code isn't guaranteed to work the same way in the future.


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  Richard.A.Williams.5@ND.Edu
WWW:    http://www.nd.edu/~rwilliam

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index