Statalist The Stata Listserver


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

Re: st: graphing rrr from mlogit


From   "Austin Nichols" <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: graphing rrr from mlogit
Date   Wed, 9 May 2007 17:53:10 -0400

Naomi--
Note that Maarten's solution (due to J. Scott Long, Jeremy Freese &
Jun Xu; see www.indiana.edu/~jslsoc/spost.htm) imposes a constant
effect of the RHS variable in the example, whereas I think you wanted
13 categories of the RHS variable "malsum" to have different effects.
The -prgen- approach is less general than the set of solutions I
outlined.  Somewhat oddly, Maarten also limits predictions to the
foreign==0 subsample. The last graph in the example below illustrates
that the predictions are quite different for the foreign==1 sample,
and the predictions at the mean of foreign available from -prgen- are
quite different from the mean of predictions.  Of course, Maarten
knows this, and is just demonstrating the use of -prgen-, but his
example might easily mislead you without the following comparison.

* get -prgen- and -locpoly-
net from http://www.indiana.edu/~jslsoc/stata
net install spost9_ado, replace
net from http://www.stata-journal.com/software/sj6-4
net inst st0053_3, replace
* begin example
clear
sysuse auto
recode rep78 1/2=3
qui mlogit rep78 length foreign
prgen length, gen(pr)
prgen length, gen(f0) x(foreign=0)
prgen length, gen(f1) x(foreign=1)
predict p3 p4 p5
su len
gen x=r(min)+(r(max)-r(min))*(_n-1)/10 in 1/11
forv i=3/5 {
locpoly p`i' len, nogr gen(pp`i') at(x)
}
loc o "leg(off)"
line prp3 prp4 prp5 prx, name(pm) ti(f=0.3) `o'
line f0p3 f0p4 f0p5 prx, name(f0) ti(f=0) `o'
line f1p3 f1p4 f1p5 prx, name(f1) ti(f=1) `o'
line pp? x, name(mp) ti(Mean predictions) `o'
gr combine f0 f1 pm mp, ycommon
li x *p3 in 1/13, noo clean

On 5/9/07, Maarten buis <maartenbuis@yahoo.co.uk> wrote:
--- Naomi Spence <spencen@email.unc.edu> wrote:
> I am using a multinomial logit model to predict type of
> violence--variable name "violence" with values 0=none,
> 1=psychological, 2=physical.  My main independent variable of
> interest is an index "malsum" that ranges from 0-12.
>
> I want a graph that depicts changes in "violence" with increasing
> values of "malsum."  I'm visualizing a graph with 3 lines--one for
> each outcome  category on "violence".  Ideally, I would like the y
> axis to show the relative risks (I'm using mlogit option rrr), but
> I'll settle for predicted probabilities. I have tried a few different
> things, but the best I can do gives me 3 separate graphs with 1 line
> each that I can "combine" to put them on one panel but I'd like to
> have the 3 lines on  the same graph.

*--------------- begin example ----------------
sysuse auto, clear
recode rep78 1/2=3
mlogit rep78 length foreign
prgen length, gen(pr) x(foreign=0)

twoway line prp3 prp4 prp5 prx, /*
*/ yscale(range(0 1)) ylab(0(.25)1) /*
*/ ytitle("probability")
*------------- end example ------------------
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index