Date: Fri, 21 Jan 2005 17:25:52 -0800
Reply-To: Dale McLerran <stringplayer_2@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Dale McLerran <stringplayer_2@YAHOO.COM>
Subject: Re: geomean questions.
Content-Type: text/plain; charset=us-ascii
--- "David L. Cassell" <cassell.david@EPAMAIL.EPA.GOV> wrote:
> Dale McLerran <stringplayer_2@YAHOO.COM> replied [in small part]:
> > To do this, you must first compute a variable
> > LOG_X = log(x) in a data step. From there, the simple way to
> > get the geometric mean of X would be to run PROC NLMIXED with
> > code
> > proc nlmixed data=mydata;
> > model log_x ~ normal(mu, var);
> > estimate "Geometric mean of X" exp(mu);
> > run;
> Okay, can we have a show of hands? Does anyone else think this
> is the SIMPLE way to get the geometric mean? :-) :-)
OK, I'll admit that the suggestion to use NLMIXED is non-intuitive.
I had not thought of it until I had started my post. Still, I
will have to argue that it is THE SIMPLE WAY to get the statistic,
at least for a single response.
We can construct a data step in which we cumulate sums and
frequencies, as David shows below. So, if we assess simplicity
in terms of how many data steps/procedures one must code in order
to get the statistic, there are "simpler" approaches.
> options nocenter nodate nonumber ps=60 ls=75 noovp;
> data temp1;
> do y = 1 to 3;
> do x = 3*y to 20*y by 3; output; end;
> y = 3; x = .; output;
> data temp2(keep = y count logsum geo_mean);
> do until(last.y);
> set temp1;
> by y;
> count = sum(count, not missing(x) );
> logsum = sum(logsum, log(x) );
> geo_mean = exp( logsum / count );
> proc print data=temp2; run;
OK, let's see those hands raised for the DoW approach versus
log_x = log(x);
proc nlmixed data=temp2;
model log_x ~ normal(mu, var);
estimate "Geometric mean" exp(mu);
Which one is simpler? Vote now. And in the spirit of recent
vote tabulations, vote often!
Fred Hutchinson Cancer Research Center
Ph: (206) 667-2926
Fax: (206) 667-5977
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.