Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Making graphs from micombine mlogit results


From   "Maarten Buis" <[email protected]>
To   <[email protected]>
Subject   RE: st: Making graphs from micombine mlogit results
Date   Tue, 24 Apr 2007 11:54:45 +0200

At 04:57 PM 4/23/2007, ucb_gal wrote:
>hi, i'm having trouble making a graph from mlogit results.  i run my
>mlogit (i'm using multiple imputation, so i use micombine first):
>micombine mlogit depvar black_nh asian_nh native_nh hisp female
>income [pw=custweight], cluster(R234)
>
>next i'm trying to create variables based on the probabilities
>generated from the mlogit:
>prgen income, x(black_nh=1) generate(blk2) ncases(20)
>
>and then i get the error:
>equation 1 not found
>r(303);
>
>what's equation 1?  what am i doing wrong?

--- Richard Williams answered:
> There is no guarantee that post-estimation commands are going to work
> correctly after micombine, let alone a user-written post-estimation
> command like prgen.
>
> I don't know if it will help, but I suggest you install -mim- and
> -mimstack-, available from SSC.  As Nick Cox posted last month,
> "-mim- replaces Patrick Royston's -micombine- (still available via
> -ssc install ice-) and has in general more facilities and greater
> rigour than -micombine-. It replaces Galati and Carlin's -mitools-.
> "  The help for -mim- indicates some things you can and cannot do
> with post-estimation commands.  I haven't tried it but it looks like
> mim's -storebv- option might let you do what you want.

Unfortunately, but not surprisingly, -mim- doesn't solve that problem
either. For one thing, you'll probably want to see the probabilities 
at the Multiple Imputation estimates of the means of the variables, 
and as -prgen- wasn't written with MI in mind it is not surprising 
that -prgen- cannot do that. More generally the data is stored in a 
way that will confuse any non-multiple imputation program. You'll 
have to compute the probabilities yourself, which isn't that hard, 
see the example below:

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

sum price, meanonly
local min = r(min)
local max = r(max)

tempfile temp

ice rep78 price mpg foreign weight using `temp', m(5)

use `temp', clear

mim: mean weight mpg
/*the means are stored in the matrix e(MIM_Q)*/
matrix mean = e(MIM_Q)
/*the first element is the mean of weight*/
scalar mweight = mean[1,1]
/*and the second element the mean of mpg*/
scalar mmpg = mean[1,2]

mim, storebv: mlogit rep78 price weight mpg foreign

gen xprice = `min' + (_n-1)*(`max' - `min')/19 in 1/20
gen double xb4 = [4]_b[price]*xprice + [4]_b[weight]*mweight /*
            */ + [4]_b[mpg]*mmpg + [4]_b[_cons]
gen double xb5 = [5]_b[price]*xprice + [5]_b[weight]*mweight /*
            */ + [5]_b[mpg]*mmpg + [5]_b[_cons]

gen p3 = 1/(1+exp(xb4)+exp(xb5))
gen p4 = exp(xb4)/(1+exp(xb4)+exp(xb5))
gen p5 = exp(xb5)/(1+exp(xb4)+exp(xb5))

twoway line p3 p4 p5 xprice in 1/20
*----------------- end example ------------------------------
(For more on how to use examples I sent to the Statalist, see:
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology 
Vrije Universiteit Amsterdam 
Boelelaan 1081 
1081 HV Amsterdam 
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434 

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------



*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index