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: Heckprob - postestimation graphs


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Heckprob - postestimation graphs
Date   Wed, 1 Dec 2010 08:31:15 +0000 (GMT)

--- On Wed, 1/12/10, James McJoseph wrote:
> Estimated Heckprob. I want to retrieve predicted
> probability (say p11, as used in stata) when one (or
> two) explanatory variable varies, the rest kept at
> means.

Normally I would say -margins-, but that will only give
you a table and no straightforward way of turning it into
a dataset (it is possible, just not straightforward). 
This is important in your case, as you stated in your
subject line that you wanted to graph these predictions.
So, I would do this from first principle: Set the variables
to the values you want to fix them, use -predict- to 
predict, than graph the predictions. Since this way you 
are seriously messing with your data, I would precede these
steps with a -preserve- and end it with a -restore-:

*---------------- begin example --------------
webuse school, clear
heckprob private years logptax, ///
    sel(vote=years loginc logptax)

preserve
// set remaining variables at their mean
foreach var of varlist logptax loginc {
	sum `var' if e(sample), meanonly
	replace `var' = r(mean)
}

// predict
predict p11, p11

//graph
twoway line p11 year, sort
restore
*------------- end example -----------------

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index