### Sunday, March 19, 2006

## st: Re: geometric mean with svy (version 9.0)

I was able to figure out the answer. after running svy:mean on log transformed variables, I typed ereturn display,eform(gm) and it gives me geometric mean and sd. I tried using foreach syntax to automate the process but was not able to run the query.

foreach x of varlist lnbenz lnchol { quietly svy:mean`x' gen gm`x'=exp(r(mean)) }

The problem here was r(mean) . Since I am running estimation i wasnt able to find any equivalence of r(mean). Here is list of scalar I got when I typed ereturn list

. svy:mean lnbenz (running mean on estimation sample)

Survey: Mean estimation

Number of strata = 13 Number of obs = 647 Number of PSUs = 27 Population size = 1.5e+08 Design df = 14

-------------------------------------------------------------- | Linearized | Mean Std. Err. [95% Conf. Interval] -------------+------------------------------------------------ lnbenz | .2441459 .221858 -.2316921 .7199839 --------------------------------------------------------------

. ereturn list

scalars: e(df_r) = 14 e(singleton) = 0 e(census) = 0 e(N_pop) = 145459402.6002451 e(N_psu) = 27 e(N_strata) = 13 e(N_over) = 1 e(N) = 647 e(N_strata_omit) = 0 e(stages) = 1 e(k_eq) = 1 e(k_eform) = 0

macros: e(cmd) : "mean" e(prefix) : "svy" e(cmdname) : "mean" e(command) : "mean lnbenz," e(title) : "Survey: Mean estimation" e(vcetype) : "Linearized" e(estat_cmd) : "svy_estat" e(varlist) : "lnbenz" e(predict) : "_no_predict" e(wtype) : "pweight" e(wvar) : "wtsvoc2y" e(wexp) : "= wtsvoc2y" e(vce) : "linearized" e(su1) : "sdmvpsu" e(strata1) : "sdmvstra" e(properties) : "b V"

matrices: e(b) : 1 x 1 e(V) : 1 x 1 e(_N_subp) : 1 x 1 e(V_srs) : 1 x 1 e(_N) : 1 x 1 e(error) : 1 x 1

functions: e(sample)

thanks for the help Ahmed.

On 3/17/06, Ahmed Arif <arifaa@gmail.com> wrote: > Dear Stata Guru's, > > I want to compute geometric mean and SD from survey data. Here is an example: > > . svy:mean lnbenz,over (sex) > (running mean on estimation sample) > > Survey: Mean estimation > > Number of strata = 13 Number of obs = 647 Number > of PSUs = 27 Population size = 1.5e+08 > Design df = 14 > > _subpop_1: sex = 0. Male > _subpop_2: sex = 1. Female > > -------------------------------------------------------------- > | Linearized > Over | Mean Std. Err. [95% Conf. Interval] > -------------+------------------------------------------------ > lnbenz | > _subpop_1 | .3884244 .2993531 -.2536241 1.030473 > _subpop_2 | .1070038 .1907388 -.3020902 .5160979 > -------------------------------------------------------------- > > I can manually type > Di exp(0.3884244) > > For each of the category but I have to type hundreds of time since I > have several variables. I tried egenmore option but I couldn't find > how to use it with svy command. Can any help point me to the resource > to find more info? Is there program I can use to automate this > process? Ideally I would like Stata to run the survey command and then > use the mean value to compute geometric mean and SD. Any help will be > greatly appreciated > > Thank you > Ahmed > Ahmed A. Arif, MD., PhD > Assistant Professor & Director > Health Services Research Program > Department of Family and Community Medicine Texas Tech University > Health Sciences Center > 3601 4th St, STOP 8161 > Lubbock, TX 79430 > Tel: 806-743-3048 > Fax: 806-743-1292 > email: ahmed.arif@ttuhsc.edu >

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

Tag: statalist