Statalist


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

RE: st: Saving svy mean estimates?


From   "Kanter, Rebecca" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: Saving svy mean estimates?
Date   Tue, 7 Apr 2009 21:44:41 -0400

Thanks Matt!-works great; gives same values as the linearized-SE from the original svy mean command, as it should.
___________________________________________
Rebecca M. Kanter
PhD Candidate
Johns Hopkins Bloomberg School of Public Health
Department of International Health
Center for Human Nutrition
________________________________________
From: [email protected] [[email protected]] On Behalf Of Matt Spittal [[email protected]]
Sent: Tuesday, April 07, 2009 8:24 PM
To: [email protected]
Subject: Re: st: Saving svy mean estimates?

Rebecca,

Others are more proficient than me at using the matrix functions.  But the
principle to extract standard errors is the same as the means, but requires
a little extra work.  The variance-covariance matrix is stored in -e(V)-,
and we need the square root the diagonal elements to get the SEs.

    webuse highschool, clear
    svyset county [pweight=sampwgt], strata(state) vce(linearized)
    svy: mean weight, over(sex)

    matrix V = e(V)             // <- gets the variance-covariance matrix
    matrix Var = vecdiag(V)     // <- gets the diagonal elements

    svmat Var
    replace Var1 = sqrt(Var1)   // <- take the square root to get SEs
    replace Var2 = sqrt(Var2)

No doubt there is a more efficient method to get the square root of the
diagonal elements. Others may have some thoughts on this.

-- Matt
[email protected]




On 8/4/09 10:52 AM, "Kanter, Rebecca" <[email protected]> wrote:

> Thanks again everyone...
>
> Now this may be asking too much, but following the below example of saving the
> matrix of mean values to variables...does anyone know how to save their
> corresponding standard errors (SEs) as a matrix and/or variable(s)? Thanks.
> [prior example:]
>     webuse highschool, clear
>     svyset county [pweight=sampwgt], strata(state) vce(linearized)
>     svy: mean weight, over(sex)
>     matrix means =  e(b)
>     matrix list means
>     svmat means     // <-- This line creates two new variables
> ________________________________________
> From: [email protected]
> [[email protected]] On Behalf Of Matt Spittal
> [[email protected]]
> Sent: Tuesday, April 07, 2009 7:46 PM
> To: [email protected]
> Subject: Re: st: Saving svy mean estimates?
>
> Rebecca,
>
> You can use the -svmat- command to create a variable from a matrix.  From
> the examples given previously
>
>     webuse highschool, clear
>     svyset county [pweight=sampwgt], strata(state) vce(linearized)
>     svy: mean weight, over(sex)
>     matrix means =  e(b)
>     matrix list means
>
>     svmat means     // <-- This line creates two new variables
>
> I hope this is helpful.
>
> -- Matt
> [email protected]
>
>
>
>
>
>
> On 8/4/09 10:30 AM, "Kanter, Rebecca" <[email protected]> wrote:
>
>> Joao,
>> Thanks for your response; that helps a bit. But what I'm trying to get at is
>> how to store the e(b) (i.e. mean values) into a variable [the same way as if
>> I
>> did egen newvar=mean(var), without acct for svy design]. Do you or someone
>> else know how to do this?
>> Many thanks,
>> Rebecca
>> ___________________________________________
>> Rebecca M. Kanter
>> PhD Candidate
>> Johns Hopkins Bloomberg School of Public Health
>> Department of International Health
>> Center for Human Nutrition
>> ________________________________________
>> From: [email protected]
>> [[email protected]] On Behalf Of Joao Ricardo F. Lima
>> [[email protected]]
>> Sent: Tuesday, April 07, 2009 7:13 PM
>> To: [email protected]
>> Subject: Re: st: Saving svy mean estimates?
>>
>> Rebecca,
>>
>> the svy mean estimates are saved in e(b)
>>
>> *********begin example*************
>> webuse highschool, clear
>> svyset county [pweight=sampwgt], strata(state) vce(linearized)
>> svy: mean weight, over(sex)
>> eret li
>> mat li e(b)
>> *********end example*************
>>
>> Sorry but I didn´t understand the second part of your question.
>>
>> HTH,
>>
>> Joao Lima
>>
>> 2009/4/7 Kanter, Rebecca <[email protected]>:
>>> Hi,
>>>
>>> I am using the svy mean command to calculate survey weighted state-specific
>>> mean estimates of different Mexican state characteristics, for example the
>>> percent of the population in a specific Mexican state that is indigenous
>>>
>>> Thus, I use the following command line: svy: mean indigena, over(state)
>>>
>>> And want to save these mean estimates (by state) as I would if I did an by
>>> state, sort: egen mean(indigena)--that was not accounting for the survey
>>> design; so my question is, how do I save the mean estimates by state from
>>> the
>>> above svy command line: svy: mean indigena, over(ent)??  And/or how do i
>>> save
>>> mean estimates for this that does take the svy pweight into account in the
>>> proper manner (if I can't do it with svy: mean)? [I want to then drop people
>>> from my dataset but want to have all the state estimates of characteristics
>>> saved as variables before doing so].
>>>
>>> Thanks,
>>> Rebecca
>>>
>>>
>>> ___________________________________________
>>> Rebecca M. Kanter
>>> PhD Candidate
>>> Johns Hopkins Bloomberg School of Public Health
>>> Department of International Health
>>> Center for Human Nutrition
>>>
>>> *
>>> *   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/
>>>
>>
>>
>>
>> --
>> ----------------------------------------
>> Joao Ricardo Lima, D.Sc.
>> Professor
>> UFPB-CCA-DCFS
>> Fone: +5538387264913
>> Skype: joao_ricardo_lima
>> ----------------------------------------
>>
>> *
>> *   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/


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