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

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


From   Roger Newson <[email protected]>
To   [email protected]
Subject   st: RE: RE: RE: ci, return lists, and statsby commands
Date   Thu, 02 Oct 2003 11:07:29 +0100

At 12:17 30/09/03 +0100, Nick Cox wrote:
Wallace, John
>
> Sorry for the cryptic original message.  The problem arises
> when you have
> more than one variable you're using ci on:
>
> . sysuse auto
> . statsby "ci price mpg" mean = r(mean) upper = r(ub) lower = r(lb)
> foldrange = (r(ub)/r(lb)), by(for)
>
> The output will only show the data for mpg, the price data
> gets overwritten
> before statsby acts on it.
>
> Is there some sort of dataset structure I could use to loop
> through a series
> of variables summarizing them with -ci- and tabulating the
> r() values?

Here's one way. Another way would be to
do -statsby- separately for each variable
and -merge- the results. Another way
would be to -stack- your responses into
one variable and then apply -statsby-.
There are, no doubt, yet other ways.
One possible other way might be to use -parmby- (part of tthe -parmest- package) instead of -statsby-, and to use the -regress- command to generate the means for each variable, and then to use -dsconcat- to concatenate the output data sets for each variable. For instance, John might write a program

local i1=0
foreach X of var price mpg weight length {
local i1=`i1'+1
tempfile tf`i1'
parmby "regress `X'", saving(`tf`i1',replace) ylabel
}
dsconcat `tf1' `tf2' `tf3' `tf4'
gene foldrange=max95/min95

This will create a data set in the memory with 1 observation per variable and data on parameter estimates, confidence limits, P-values and fold ranges, overwriting the existing data. Optionally, the user can also save other estimation results, such as sample numbers.

To find out more about the -parmest- and -dsconcat- packages, type -ssc desc parmest- or -ssc desc dsconcat- inside Stata. More information about these and other packages for post-processing results can be found in Newson (2003), which can be downloaded as a pre-publication draft from my website at
http://www.kcl-phs.org.uk/rogernewson/
either using a browser or using the Stata -net- command.

I hope this helps.

Roger

References

Newson R. Confidence intervals and p-values for delivery to the end user. The Stata Journal 2003; 3(3): 245-269.


--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Email: [email protected]
Website: http://www.kcl-phs.org.uk/rogernewson

Opinions expressed are those of the author, not the institution.

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