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]

Re: st: Contour plot help


From   Bill Rising <[email protected]>
To   Stata Listserv <[email protected]>
Subject   Re: st: Contour plot help
Date   Tue, 26 Feb 2013 17:57:49 -0600

Carolina Echevarria <[email protected]> asked about making a contour plot from the results of -margins- similar to that shown on the last slide of
  http://www.stata.com/meeting/chicago11/materials/chi11_rising.pdf

She was running a -logit-, followed by -margins-, followed by -estimates store-

> quietly logit outcome varX varY 
> margins, at( varX=(1(0.5)5))
> I try to save the margins using estimates store, but didnt work

To get the two dimensions for the x and y variables in the contour plot, she needs to also have some values for varY (see below).

Instead of using -estimates store- to create a dataset for the graph she needs to use the undocumented function _marg_save, which is used to create a dataset from the margins.

Here are a few lines of code which put the margins in the dataset named forContour.dta, which I am happy to overwrite, as its only purpose is to make the graph. I made up values for the varY variable, but she should use useful ones:

  margins, at( varX=(1(0.5)5) varY=(10(1)20))
  _marg_save, saving(forContour, replace) 
  preserve // so the original dataset can be recovered
  use forContour, clear
  twoway contour _merge _at1 _at2, ccuts(0(0.05)0.5)  
  restore // to recover the original dataset

For future reference: here is a zip file containing the do-file used to make the graph in the talk:
  http://www.stata.com/meeting/chicago11/materials/chi11_rising_files.zip

Cheers,

Bill Rising
[email protected]  
*
*   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