 Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# RE: st: RE: Test of differences between geometric means

 From Nick Cox To "'statalist@hsphsun2.harvard.edu'" Subject RE: st: RE: Test of differences between geometric means Date Tue, 15 Nov 2011 18:41:28 +0000

```I just want to emphasise that this program does nothing to verify whether data are (or are not) lognormal. It just calculates geometric mean and SD for a variable that is always positive [in the observations selected].

The question of whether a variable is lognormal can be addressed using -lognfit- (SSC) and -qpfit- (SSC).

Nick
n.j.cox@durham.ac.uk

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: 15 November 2011 18:31
To: 'statalist@hsphsun2.harvard.edu'
Subject: RE: st: RE: Test of differences between geometric means

The majority of user-written programs were written because the programmers wanted to use them themselves. So, you may need to write what you want to use. Meanwhile here is one sketch.

*! 0.1.0 NJC 15 Nov 2011
program geomsu, rclass
version 9
syntax varname(numeric) [if] [in]
marksample touse

qui count if `touse'
if r(N) == 0 error 2000

qui count if `touse' & `varlist' <= 0
if r(N) > 0 error 411

quietly {
tempvar work
gen `work' = log(`varlist') if `touse'
su `work'

local fmt : format `varlist'
}

di
di "geometric mean  " `fmt' exp(r(mean))
di "geometric SD    " `fmt' exp(r(sd))

return scalar gmean = exp(r(mean))
return scalar gsd = exp(r(sd))
end

Nick
n.j.cox@durham.ac.uk

Junlin Liao

I'm wondering if someone could write a procedure to summarize
lognormal data automatically in the form of geometric mean and std
etc. It's easy to transform data to get the results, but it would be
nice if it's automated. The means commands (gmeans or ameans) do not
give standard deviation.

On Tue, Nov 15, 2011 at 3:41 AM, Nick Cox <n.j.cox@durham.ac.uk> wrote:

> There is I believe some literature on ad hoc tests for this question, but the results of
>
> . findit lognormal
>
> do not show any Stata implementations. I'd recast the problem as one of estimating a model using either -glm, link(log) f(normal)- or -lognfit- (SSC).
>
> Nick
> n.j.cox@durham.ac.uk
>
> N.M.Postel-Vinay@lse.ac.uk
>
> Is there a test of differences between geometric means, assuming lognormal distributions?

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