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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st:graph mean with missing groups


From   Amanda Fu <mandy.fu1@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st:graph mean with missing groups
Date   Sun, 15 Jul 2012 16:11:46 -0400

Hello Mr. Nick,
Thank you for your response. I understand your suggestion and I knew
my question is not clear enough. I find an alternative way to deal
with the problem I encountered. Thank you!
Amanda
On Sun, Jul 15, 2012 at 2:18 PM, Nick Cox <njcoxstata@gmail.com> wrote:
> This seems puzzling and contradictory to me, which may explain the
> lack of replies.
>
> If groups are empty then the mean of any other variable is undefined
> and Stata's refusal to plot the mean is reasonable. It is unknown, or
> missing, and not 0.
>
> On the other hand if what Amanda wants is some kind of histogram or
> bar chart, then that can be obtained directly e.g. by -histogram- or
> -twoway histogram- and Stata will show empty groups as having zero
> frequency, or percent, or density. Such a histogram can be forced to a
> line chart by e.g.
>
> twoway histogram ... , recast(line)
>
> Nick
>
> On Sat, Jul 14, 2012 at 1:13 AM, Amanda Fu <mandy.fu1@gmail.com> wrote:
>
>> I am stuck with drawing a graph about means of a test score variable
>> by groups. The problem is caused by there are some "empty" groups.
>>
>> The variable "score" range from 0 to 100. I cut it into 10 bands : 0,
>> 1-10, 11-20,21-30,...,91-100. I create a new variable "score_percent"
>> indicates the percent for the share of observations in each band.
>> The data set is like:
>> id   score   score_percent
>> 1      32           3.8         (Totally 3.8% observations have scores
>> between 31-40)
>> 2      89         23.4
>> 3      67         16.5
>> ...................
>> I tried to use the following command to create a graph for mean level
>> of test scores:
>> .twoway connected   score_percent    score ,xlabel(0(10)100)
>> -------------------------
>> However, in the data set none observations have scores from 11-20. So
>> this is an empty band. The value of "score_percent" for this band
>> should be 0. But if I use the above command to draw the graph, the
>> connected line will skip the empty band and directly jump to the next
>> point (it is like, along the x-axis there are band 0-10, 21-30,.....).
>> What I wanted is to give the empty band with percent share is 0.
>> I wonder if someone can give me some suggestion how to fix this. Thank you!
>>
> *
> *   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index