# Re: st: using svymean output

 From Stas Kolenikov To statalist@hsphsun2.harvard.edu Subject Re: st: using svymean output Date Tue, 21 Sep 2004 10:13:23 -0400

```Janet,

that indeed is a very frequently asked question :)). I've just posted
a response to a very similar one yesterday.

For the first part, you would use _b[x], as long as -svymean- is an
estimation command. Also, \$S notation probably works, but is totally
obsolete. The modern way is to use e(N) for the first one... and as
for the second one, I would probably do

mat DEFF = e(deff)

and then look at the entries of that matrix.

For the second part, you would indeed use -svymean, by()-, and then
either -test- it or -lincom- it. The syntax is sort of described in
-help test-, but requires some trial and error to get through:

<pre>
. sysuse auto
(1978 Automobile Data)

psu is rep78

. svymean price, by(for)

Survey mean estimation

pweight:  headroom                                Number of obs    =        69
Strata:   <one>                                   Number of strata =         1
PSU:      rep78                                   Number of PSUs   =         5
Population size  =       207

------------------------------------------------------------------------------
Mean   Subpop. |   Estimate    Std. Err.   [95% Conf. Interval]        Deff
---------------+--------------------------------------------------------------
price          |
Domestic |   6317.291    238.8972    5654.006    6980.576    .2866435
Foreign |   6008.935    262.4074    5280.375    6737.495    .2516833
------------------------------------------------------------------------------

. eret li

scalars:
e(df_r) =  4
e(N) =  69
e(N_strata) =  1
e(N_psu) =  5
e(N_pop) =  207
e(n_by) =  2

macros:
e(cmd) : "svymean"
e(predict) : "svy_x_p"
e(varlist) : "price"
e(complete) : "complete"
e(depvar) : "Mean"
e(label) : "label"
e(by) : "foreign"
e(psu) : "rep78"
e(wtype) : "pweight"

matrices:
e(b) :  1 x 2
e(V) :  2 x 2
e(V_db) :  2 x 2
e(est) :  1 x 2
e(error) :  1 x 2
e(_N) :  1 x 2
e(_N_subp) :  1 x 2
e(V_msp) :  2 x 2
e(V_srs) :  2 x 2
e(meft) :  1 x 2
e(deft) :  1 x 2
e(deff) :  1 x 2

functions:
e(sample)

. test [price]Domestic = [price]Foreign

( 1)  [price]Domestic - [price]Foreign = 0

F(  1,     4) =    0.40
Prob > F =    0.5635

. lincom [price]Domestic - [price]Foreign

( 1)  [price]Domestic - [price]Foreign = 0

------------------------------------------------------------------------------
Mean |   Estimate   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
(1) |   308.3557   490.2406     0.63   0.563    -1052.771    1669.482
------------------------------------------------------------------------------

.
</pre>

On Tue, 21 Sep 2004 08:51:16 -0400 (EDT), Janet E. Rosenbaum
<jerosenb@hcs.harvard.edu> wrote:
> Sorry if this is a FAQ, but I didn't see it in a search on the mailing
> list archives or in help or in looking through the FAQ.
>
> Two part question:
>
> 1.  Where is there a list of the designations for the output for a command?
> For instance, the example below is on the FAQ.  I tried guessing how
> to display the estimate, like _mean[x] and _est[x] to no avail.
>
> svymean x
> Mean |   Estimate    Std. Err.   [95% Conf. Interval]        Deff
> ---------+--------------------------------------------------------------------
>    x |   7.497354    1.154104    4.925852    10.06886    1.826019
>
> di _se[x]*sqrt(\$S_E_nobs/S_E_deff[1,1])
>     3.9138278
>
> Also, is there some way just to treat the output as a matrix without the
> names?
>
> 2.  Eventually, for y a binary variable, I'd like to do
> svymean x, by(y)
> and ttest whether estimates are equal at the two levels of y.
>
> How would I call the components of this?
>
> Mean   Subpop. |   Estimate    Std. Err.       Deff         Obs
> ---------------+--------------------------------------------------------------
> x              |
>         y==0   |   6.252655    .2913123    .9953564        2402
>         y==1   |   5.087685    .6354503     1.30706         214
>
> Janet
> --
> Janet Rosenbaum                                 jerosenb@fas.harvard.edu
> PhD Candidate in Health Policy, Harvard GSAS
> Harvard Injury Control Research Center, Harvard School of Public Health
> *
> *   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/
>

--
Stas Kolenikov
http://stas.kolenikov.name
*
*   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/
```