Statalist


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

Re: st: RE: RE: Useing e(over_labels)


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: RE: RE: Useing e(over_labels)
Date   Fri, 10 Jul 2009 12:18:42 -0400

Richard Palmer-Jones<[email protected]>:
There are a variety of ways to loop over categories and collect
results, but note that the approach you give does not agree with the
results of -svy:mean- (check your CIs), and does not collect the
values of categorical variables (e.g. NE and E both become E).  My
question stands--what do you want this for?  The goal dictates the
preferred method.  For example, if you wanted to write out a formatted
table, an easy way to go is to use -estout- e.g.

use nhanes2, clear
la def smsa 1 "City" 2 "Noncity SMSA" 4 "NonSMSA"
la val smsa smsa
egen subpop=group(smsa region), label
svy: mean bpsystol, over(subpop) nohe noleg
qui ta subpop, gen(i_) label
qui svy: reg bpsystol i_*, nocons
eststo smsa
esttab smsa, nogap varw(25) la b(%9.4f) ci(%9.4f) nostar

or to an MSWord file:

esttab smsa using t.doc, rtf nogap varw(25) la b(%9.4f) ci(%9.4f) nostar

On Fri, Jul 10, 2009 at 11:24 AM, Richard
Palmer-Jones<[email protected]> wrote:
> Sorry, I was taking a short cut - yes I want the ses - my problem
> was/is to access the e(over_labels) which consist of two comonents
> separated by a space.
>
> So to add ses I can
>
> .....
> mat ev = vecdiag(e(V))'
> mat eb = e(b)'
> mat en = e(_N)'
> mat evn = eb,ev,en
>
> drop _all
> svmat evn
> gen row = ""
> forval o = 1/`c(N)' {
>        local r : label g `o'
>        replace row = "`r'" in `o'
> }
> gen var1 = substr(row, 1, 2)
> gen var2 = substr(row, -1, 1)
> gen lb = evn1 - invttail(evn3-1,0.025) * (evn2^0.5 * sqrt(evn3) / sqrt(evn3))
> gen ub = evn1 + invttail(evn3-1,0.025) * (evn2^0.5 * sqrt(evn3) / sqrt(evn3))
>
> gives me the ses
>
> But I am disappointed I cannot captuer the over_labels in am ore
> elegant way, and was just thinking there must be a way to parse the
> e(over_labels) macro in a better way. but the spaces between "NE and
> "1`" were defeating me until I came upon the "local r : label
> labelname # " wheeze.
>
> So, expecting enlightenment
> On Fri, Jul 10, 2009 at 3:02 PM, Austin Nichols<[email protected]> wrote:
>> Richard Palmer-Jones<[email protected]>:
>>
>> I don't understand--if indeed you only want the weighted means and not
>> the SEs, then use -collapse- and get there in one line, and note that
>> pweights and aweights are equivalent if you do not need SEs.  What do
>> you need this dataset of summary stats for, anyway? The goal dictates
>> the preferred method, in general.  My point was just that the labels
>> (both numeric and string) for the -over- variable are easy to access.
>>
>> Also, it looks like in your original post you said "I want to compuile
>> the ereturned e(b) and e(v) results of a -mean var1, over(var2 var3,
>> nolabel)- into a usable form, such as rows in new variables or a
>> matrix, together with the relevatn values of var2 & var3" so a matrix
>> is what you asked for...
>>
>> On Fri, Jul 10, 2009 at 9:35 AM, Richard
>> Palmer-Jones<[email protected]> wrote:
>>> and then extracting the two values gives me the result I wan - a file
>>> with the resulsts of svy: mean ..  , over()
>>>
>>>     |       v1    row   var1   var2 |
>>>     |-------------------------------|
>>>  1. | 125.7034   NE 1     NE      1 |
>>>  2. | 127.8939   NE 2     NE      2 |
>>>  3. | 129.4605   NE 4     NE      4 |
>>>  4. | 126.8856   MW 1     MW      1 |
>>>  5. |  126.381   MW 2     MW      2 |
>>>     +-------------------------------+
>>>
>>>
>>> I am sure there are more elegant ways to do this, but I cannot get the
>>> more obvious ones to work for reasons I am sure are obvious to adpets.

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