[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: AW: use of histogram option |

Date |
Thu, 30 Apr 2009 00:02:58 +0200 |

<> So here is my best guess what Linn wants, implemented with -graph bar-. The -asis- option seemed better to me than to have the -graph- command calculate my statistics... ************* clear* //construct the data //1000 districts set obs 1000 gen district=_n //just an educated guess :-) gen population=rnormal(200000,30000) //40 % religious districts (your dummy) gen byte religious=runiform()>0.6 //wealth inside the districts (skewed) (your continuous var) gen wealth=rchi2(5) //data construction done ****************** //upstream work //get quartiles beforehand xtile quartile=population, nq(4) ****************** //get first graph //preserve for second run (i.e. wealth) preserve //get data first run qui table quartile, contents(mean religious ) row replace //overall comes back missing so change it replace quartile=5 if quartile==. // get label la def quart 1 "First Quartile" 2 "Second Quartile" /// 3 "Third Quartile" 4 "Fourth Quartile" 5 "Overall" la val quartile quart //get separation gen byte new=quartile!=5 //get graph //no draw here, -graph combine- later graph bar (asis) table1, over(quartile) over(new, axis(off)) /// nofill name(first, replace) nodraw title("Proportion of Religious People") /// note("According to Population Quartiles") //restore from first run restore ****************** //get second graph //second run //no preserve as we are done afterwards :-) table religious quartile, contents(mean wealth) row col replace //overall comes back missing so change it replace quartile=5 if quartile==. // get label la def quart 1 "First Quartile" 2 "Second Quartile" /// 3 "Third Quartile" 4 "Fourth Quartile" 5 "Overall" la val quartile quart la def relig 0 "not religious" 1 "religious" la val religious relig //get separation gen byte new=quartile!=5 graph bar (asis) table1, over(quartile) over(religious, label(angle(forty_five))) /// over(new, label(nolabel)) nofill name(second, replace) nodraw legend(off) /// title("Mean Wealth") note("According to Religious Believes and Population Quartiles") ****************** //combine 'em graph combine first second, cols(1) ************* HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Linn Renée Naper Gesendet: Mittwoch, 29. April 2009 21:13 An: statalist@hsphsun2.harvard.edu Betreff: st: use of histogram option I want to use Stata to make some nice histogram showing some distributional features of my data, but unfortunately I have some problems in finding out how to do it. I've been able to do the following in Excel earlier, but I like the look of the Stata graphics much more, so I hope someone can give me a clue: Well, I want to use three variable making the histograms. The first is an indicator of size for my observations (population size in districts), and the two other variable are a dummy variable and a continuous variable describing the districst. First; I'd like to make a histogram with five boxes. The first box should simply give me the mean of the dummy variable for all district, whereas the four next should give the mean of the dummy variable within each population quartile of the sample. Second I'd like to add another histogram under the first one where I in the same way show the mean of the continuous variable, only here I'd like to categorize the boxes both by population size and the value of the dummy. Thus, the first two boxes should give the mean value of the continuous variable for all districts with dummy value 0 and value 1. The next two should give the same figures for the districts only in the first population quartile, then the second quartile and so on. I would also be nice if I could add some extra space between the boxes for the total sample, and for the four different quartiles respectively. Thanks to anyone who can help me ! L * * 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/ * * 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/

**Follow-Ups**:**st: AW: AW: use of histogram option***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**References**:**st: use of histogram option***From:*Linn Renée Naper <linn.naper@ecgroup.no>

- Prev by Date:
**Re: st: Problems integrating JEdit and STATA using Windows Vista** - Next by Date:
**st: AW: AW: use of histogram option** - Previous by thread:
**st: AW: use of histogram option** - Next by thread:
**st: AW: AW: use of histogram option** - Index(es):

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