Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Re: Adding a oneway plot to marginsplot


From   "Lindsay M. Pettingill" <[email protected]>
To   [email protected]
Subject   st: Re: Adding a oneway plot to marginsplot
Date   Fri, 26 Jul 2013 16:55:48 -0400

I was able to figure this out with the help of an older piece by N.
Cox (2004): "Speaking Stata: Graphing distributions."

Run margins, then store estimates and confidence intervals as new
variables- I called them est lb and ub
gen pipe="|" if [var]!=. to produce the line to draw, since a pipe is
not a default option
gen where=0 to anchor the plot on the graph at 0

Plot and connect the dots, and overlay the pipes:
twoway connected est lb ub [var] || scatter where [var], ms(none)
mlabel(pipe) mlabpos(0) legend(off)

I then did some quick editing in Graph Editor.

Lindsay

On Fri, Jul 26, 2013 at 4:13 PM, Lindsay M. Pettingill
<[email protected]> wrote:
> Hello,
> I'd like to add a oneway plot (such as that produced by the old  gr7
> var, oneway command) or a "rug" to a marginsplot. I am able to create
> both the marginsplot and the oneway plot separately but cannot
> successfully combine them.
>
> Here is the code I am using, after running the regression and margins command:
> marginsplot, recast(line) recastci(rline) addplot (onewayplot var)
> I have also tried
> marginsplot, recast(line) recastci(rline) addplot (gr7 var, oneway)
>
> For each of these, the marginsplot looks great, but the overlay is
> missing, though there is a legend indicating "1".
>
> (I have also tried taking the estimates and 95% confidence intervals
> from the margins output, and making a separate file, but it is unclear
> how to produce the rug from this.)
>
> Any suggestions would be greatly appreciated!
>
> Thank you,
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index