Statalist


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

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


From   Richard Palmer-Jones <richard.palmerjones@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: RE: Useing e(over_labels)
Date   Fri, 10 Jul 2009 14:35:17 +0100

wonderfull - but not quite since I want to save the results with
values (or labels) of  both variables in the group variable (g).
but when using


svy: mean  bpsystol, over(region smsa, nolabel)
mat b=e(b)
mat colnames b= `e(over_labels)'
mat li b

drop _all
svmat b
xpose, clear
gen row = ""
forval o = 1/`c(N)' {
	local r : label g `o'
	replace row = "`r'" in `o'
}

list

     +-----------------+
     |       v1    row |
     |-----------------|
  1. | 125.7034   NE 1 |
  2. | 127.8939   NE 2 |
  3. | 129.4605   NE 4 |
  4. | 126.8856   MW 1 |
  5. |  126.381   MW 2 |
     |-----------------|
  6. | 127.6242   MW 4 |
  7. | 127.0757    S 1 |
  8. | 123.8047    S 2 |
  9. |  127.561    S 4 |
 10. | 125.6318    W 1 |
     |-----------------|
 11. | 125.0983    W 2 |
 12. | 128.6279    W 4 |

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.

THanks for all help

Richard




On Thu, Jul 9, 2009 at 4:02 PM, Nick Cox<n.j.cox@durham.ac.uk> wrote:
> I stand corrected. See dictionary entries for hubris.
>
> Nick
> n.j.cox@durham.ac.uk
>
> Austin Nichols
>
> Richard Palmer-Jones et al.--
>
> Note that -collapse- does not support -svy- for this kind of problem:
> "pweights may not be used with sd, semean,..."
> But the obvious solution is simply to label the columns of a matrix,
> and -egen group, label- before -mean- will give nicer labels:
>
> webuse nhanes2, clear
> egen g=group(region smsa), label
> svy: mean  bpsystol, over(g)
> mat b=e(b)
> mat colnames b= `e(over_labels)'
> mat li b
>
>
> On Thu, Jul 9, 2009 at 10:38 AM, Nick Cox<n.j.cox@durham.ac.uk> wrote:
>> Just use -collapse- as recommended and this problem, such as it is, becomes irrelevant. As the help tells you, -collapse- supports all kinds of weights. Being clueless is not an excuse for not reading what is provided!
>>
>> Nick
>> n.j.cox@durham.ac.uk
>>
>> Richard Palmer-Jones
>>
>> Thanks folks, indieed, but .. it is the values of the _subpops that I
>> want to use - in martyen's case the values of foreign and rep78
>>
>> . mean mpg, over(for rep,  nolabel)
>>
>> Mean estimation                     Number of obs    =      69
>>
>>         Over: foreign rep78
>>    _subpop_1: 0 1
>>    _subpop_2: 0 2
>>    _subpop_3: 0 3
>>    _subpop_4: 0 4
>>    _subpop_5: 0 5
>>    _subpop_6: 1 3
>>    _subpop_7: 1 4
>>    _subpop_8: 1 5
>>
>> --------------------------------------------------------------
>>        Over |       Mean   Std. Err.     [95% Conf. Interval]
>> -------------+------------------------------------------------
>> mpg          |
>>   _subpop_1 |         21          3      15.01359    26.98641
>>   _subpop_2 |     19.125   1.328768      16.47348    21.77652
>>   _subpop_3 |         19   .7862783      17.43101    20.56899
>>   _subpop_4 |   18.44444   1.528535       15.3943    21.49459
>>   _subpop_5 |         32          2      28.00906    35.99094
>>   _subpop_6 |   23.33333   1.452966      20.43398    26.23268
>>   _subpop_7 |   24.88889   .9043789      23.08423    26.69355
>>   _subpop_8 |   26.33333   3.122499      20.10248    32.56418
>> --------------------------------------------------------------
>>
>>
>> and, I should have said I am using svy: mean for important reasons.
>> collapse  does not have a svy equivalent, I think?
>>
>> I cannot see an option on parmest to use the e(over_labels), so, still
>> in the dark I am afraid.
>>
>> Richard
>>
>>
>> On Thu, Jul 9, 2009 at 12:56 PM, Nick Cox<n.j.cox@durham.ac.uk> wrote:
>>> Using -collapse- is another (and easier) possibility.
>>>
>>> Nick
>>> n.j.cox@durham.ac.uk
>>>
>>> Martin Weiss
>>>
>>> cap ssc inst parmest
>>> sysuse auto, clear
>>> mean mpg, over(for rep,  nolabel)
>>> parmest, saving(myfile, replace)
>>> u myfile, clear
>>> drop eq t dof
>>> l
>>>
>>> Richard Palmer-Jones
>>>
>>> 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
>>>
>>> I think this means making use of the values in e(over_labels), but how
>>> to do so escapes me.
>>
>> *
>> *   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/
>
> *
> *   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   |   What's new   |   Site index