Statalist The Stata Listserver


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

RE: st: Graphing complex sample data in Stata 9


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Graphing complex sample data in Stata 9
Date   Thu, 14 Sep 2006 12:33:22 +0100

To add some elaboration to Uli's excellent theme: The same 
general issue arose at various points in the recent London 
users' meeting. 

For example, Roger Newson's programs 
-parmby- and friends should be useful to you, as Uli 
mentioned. 

Within official Stata, -statsby:- is always there for 
you. Here is a dopey example, not using -svy:-, but 
the same point holds. 

. sysuse auto, clear
(1978 Automobile Data)

. statsby ub=r(ub) lb=r(lb) se=r(se) mean=r(mean) N=r(N), by(foreign) total : ci price
(running ci on estimation sample)

      command:  ci price
           ub:  r(ub)
           lb:  r(lb)
           se:  r(se)
         mean:  r(mean)
            N:  r(N)
           by:  foreign

Statsby groups
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
..

. l, nola

     +----------------------------------------------------------+
     | foreign         ub         lb         se       mean    N |
     |----------------------------------------------------------|
  1. |       0   6934.663   5210.184   429.4911   6072.423   52 |
  2. |       1   7547.174    5222.19   558.9942   6384.682   22 |
  3. |       .     6848.6   5481.914   342.8719   6165.257   74 |
     +----------------------------------------------------------+

. replace foreign = 2 in 3
(1 real change made)

. label def origin 2 "Total", add

. twoway rcap ub lb foreign || scatter mean foreign, xla(0/2, val notick) 
yla(, ang(h)) xsc(r(-0.5,2.5) legend(off) 
subtitle(means and 95% confidence intervals) ytitle("Price, USD")

Anyone knowing -ciplot- from SSC will realise that this device renders
-ciplot- pretty well superfluous. 

Vince Wiggins added the nice tip (a "Yes, of course!" tip once you 
see the point): Even if you have no -by:- variable, you just need
to create a dummy [comforter] to satisfy the infant, and then 
-statsby- is useable. 

gen all = 1 
statsby ... , by(all) : ... 

Nick 
[email protected] 

Ulrich Kohler
 
> Honey, Wayne, DOH wrote:
> > I find no reference to a corresponding special set of 
> graphics commands
> > for use with complex sample data.  In fact, I find no discussions
> > whatsoever regarding the graphing of complex sample data.  
> Does anyone
> > know where one can find information that will settle my 
> concerns that
> > Stata's graphs will present properly generated proportions/means,
> > confidence intervals, etc., for complex samples?
> 
> I have a general note on this. The graphs you are looking for 
> can be "easily" 
> produced with Stata. Therefore you have to apply the 
> "resultsset" concept, 
> which is fairly general and not restricted to the complex 
> sample statistics. 
> It goes like this:
> 
> (1) Calculate the statistics with the commands you like
> (2) Collect the statistics in a data set ("resultsset")
> (3) Load the resultsset
> (4) Draw the results using standard graph commands.
> 
> Below my signature  is an example for producing and graphing 
> a resultsset for 
> a survey statistic which I accidentely made yesterday. It 
> uses -postfile-, 
> which is sort of low level. Several helper programs, mostly 
> by Roger Newson, 
> exist for the concept in general. -findit resultsset- will 
> point you to these programs.

<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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index