Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: RE: RE: RE: ci, return lists, and statsby commands


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: RE: RE: ci, return lists, and statsby commands
Date   Tue, 30 Sep 2003 19:15:11 +0100

Roger Newson has written a large series of programs, and
a series of papers explaining them. You should check out
the paper pointed to by -findit enduser-; the printed version
of that is in Stata Journal at SJ 3(3): 245-269 (2003).

Other than that, the references closest to what I
think you want are also in SJ, namely SJ 2(2): 202-222 (2002)
and SJ 3(2): 185-202 (2003). The first is also available
on the web somewhere as a series of OHP slides for a talk
based on it.

As it's my job, I ought to push the Stata Journal here,
as it contains most of the expository writing on Stata you
can find, other than the manuals and the FAQs and
material based directly on those.

Recently, I wrote -makematrix- (on SSC) as one implementation
of the idea of setting up a matrix and then populating
it with results. That's not designed to work directly
with -by:-, partly because I really didn't want to work
hard at reinventing -statsby-. (Also, I went on vacation,
and development stopped.) However, as you demonstrated,
-statsby- doesn't deliver, directly, on your problem.
However, a prior use of -separate- opens up some possibilities:

. separate mpg, by(foreign)

              storage  display     value
variable name   type   format      label      variable label
----------------------------------------------------------------------
---------
mpg0            byte   %8.0g                  mpg, foreign == Domestic
mpg1            byte   %8.0g                  mpg, foreign == Foreign

. separate turn, by(foreign)

              storage  display     value
variable name   type   format      label      variable label
----------------------------------------------------------------------
---------
turn0           byte   %8.0g                  turn, foreign ==
Domestic
turn1           byte   %8.0g                  turn, foreign == Foreign

. makematrix, from(r(mean) r(ub) r(lb)) listwise : ci mpg? turn?

            mean         ub         lb
 mpg0  19.826923  21.147465  18.506381
 mpg1  24.772727  27.703963  21.841491
turn0  41.442308  42.546889  40.337726
turn1  35.409091  36.074633  34.743548

In other words you could have a

	varlist

and a

	byvar

then you could

foreach v of var <varlist> {
	qui separate `v', by(<byvar>)
	local newlist "`newlist' `r(varlist)'
}

makematrix, from(r(mean) r(ub) r(lb)) listwise: ci `newlist'

Other approaches are possible by virtue of -makematrix-
being able to put stuff in a named matrix, which can then
be combined with other matrices.

There will be more on -makematrix- in SJ 3(4): 2003.

Nick
[email protected]

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of
> Wallace, John
> Sent: 30 September 2003 18:36
> To: '[email protected]'
> Subject: st: RE: RE: RE: RE: ci, return lists, and statsby commands
>
>
> Thanks for the reply, Nick.  I guess I have a more general
> question about
> how to compile the results of a series of tests and display
> them in a single
> summary.  Can you point me to a reference that discusses
> building an array
> of values and then performing operations on the array?
> Your suggestion
> about doing -statsby- for each variable and then merging
> the results seems
> like a step in that direction, but rather than using a
> series of saved
> datasets can you put the results into memory somewhere,
> merge them, then
> save the final result?  There may be no advantage to doing
> this, other than
> not having a bunch of intermediate variable.dta files to delete.
>

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