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: Graphic displays or results from margins


From   "Weichle, Thomas" <[email protected]>
To   <[email protected]>
Subject   Re: st: Graphic displays or results from margins
Date   Tue, 21 Sep 2010 09:57:58 -0500

Richard,
I'm getting into the margins command as well.  Here is what I've been
able to learn so far.  After producing the predicted probabilities using
the margins command after the logistic regression, I use Roger Newsom's
parmest command to save the results in a dataset and then use the
'eclplot' command to graph the predicted probabilities with the
confidence intervals.  There are some matrices to create after the
parmest command, but I don't find it too cumbersome.  
Try this.  This will produce 4 panels in the figure.  If you feel they
are too cramped together, try using if statements on the command.

webuse nhanes2f, clear
logit diabetes i.black i.female age i.female#c.age, nolog
margins female#black, at(age = (20(10)70)) post

parmest, format(estimate min95 max95) norestore
matrix input age = (20 \ 20 \ 20 \ 20 \ 30 \ 30 \ 30 \ 30 \ 40 \ 40 \ 40
\ 40 \ 50 \ 50 \ 50 \ 50 \ 60 \ 60 \ 60 \ 60 \ 70 \ 70 \ 70 \ 70)
matrix input female = (0 \ 0 \ 1 \ 1 \ 0 \ 0 \ 1 \ 1 \ 0 \ 0 \ 1 \ 1 \ 0
\ 0 \ 1 \ 1 \ 0 \ 0 \ 1 \ 1 \ 0 \ 0 \ 1 \ 1)
matrix input black = (0 \ 1 \ 0 \ 1 \ 0 \ 1 \ 0 \ 1 \ 0 \ 1 \ 0 \ 1 \ 0
\ 1 \ 0 \ 1 \ 0 \ 1 \ 0 \ 1 \ 0 \ 1 \ 0 \ 1)
matrix vars = age, female, black
matrix colnames vars = age female black
svmat vars, names(matcol)

label define female 0 "Male" 1 "Female"
label values varsfemale female
label var varsfemale "Gender"

label define black 0 "Non-Black" 1 "Black"
label values varsblack black
label var varsblack "Race"

eclplot estimate min95 max95 varsage, rplottype(rspike)
estopts(msize(medium)) ciopts(msize(large)) ///
	xtitle("") ///
	by(varsfemale varsblack, style(compact) legend(off)
title("Predicted Probability of Diabetes ({&plusmn}95% C.I.)")) ///
	b2title("Age", color(black) size(medlarge)) ///
	xlabel(20(10)70)  ///
	ytitle("Diabetes Estimated Probability", color(black)
size(medlarge))

eclplot estimate min95 max95 varsage if varsfemale == 0 & varsblack ==
1, rplottype(rspike) estopts(msize(medium)) ciopts(msize(large)) ///
	title("Predicted Probability of Diabetes ({&plusmn}95% C.I.)")
///
	xtitle("") ///
	b2title("Age", color(black) size(medlarge)) ///
	xlabel(20(10)70)  ///
	ytitle("Diabetes Estimated Probability", color(black)
size(medlarge))


Tom Weichle
Math Statistician
Center for Management of Complex Chronic Care (CMC3)
Hines VA Hospital, Bldg 1, C202
708-202-8387 ext. 24261
[email protected] 


*
*   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