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: predict


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: predict
Date   Mon, 6 Jun 2011 12:30:54 +0200

On Mon, Jun 6, 2011 at 10:55 AM, Chiara Mussida <cmussida@gmail.com> wrote:
> Likely there is a way to automatically compute predicted prob in STATA
> (alternative to predict) to get:

You should not do this manually, the chance of making an error is just too big.

However, if you are brave/foolish enough to try, than you can do so,
and if you do not make an error you will get exactly the same results
as -predict-:

*------------------------ begin example ------------------------
sysuse auto, clear
recode rep78 1/2=3
mlogit rep78 foreign

predict double pr*, pr

gen double xb1 = _b[4:_cons] + _b[4:foreign]*foreign
gen double xb2 = _b[5:_cons] + _b[5:foreign]*foreign

gen double denom = 1 + exp(xb1) + exp(xb2)

gen double mp1 = 1/denom
gen double mp2 = exp(xb1)/denom
gen double mp3 = exp(xb2)/denom

tab pr1 mp1
tab pr2 mp2
tab pr3 mp3
*-------------------- end example ------------------------------

-- 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index