s-news
[Top] [All Lists]

Re: geometric mean

To: "Jaume" <jaguado@medicina.ub.es>
Subject: Re: geometric mean
From: Tim Hesterberg x319 <timh@insightful.com>
Date: Tue, 28 May 2002 09:06:09 -0700
Cc: Bob Baskin <BobBaskin@westat.com>, s-news@wubios.wustl.edu
In-reply-to: <000301c20308$d11f5b30$a90d74a1@med.ub.es> (jaguado@medicina.ub.es)
References: <000301c20308$d11f5b30$a90d74a1@med.ub.es>
Reply-to: timh@insightful.com (Tim Hesterberg)
>I know that this question is not new but I haven't seen the answer yet. How
>could I compute the standard deviation of the geometric mean with S-Plus?.
>Is there a function to do it? Is it correct to work with the log-data and
>then make the antilog of the confidence interval limits?.

In addition to the methods Bob Baskin suggested, you could use
the bootstrap.  E.g. if your observations are independent and
identically-distributed, then

x <- rgamma(30, 3)
boot <- bootstrap(x, exp(mean(log(x))))
boot   # note the SE (standard error) column in the results

If your data are not i.i.d. you may be able to use some of the
other options to bootstrap to get an appropriate answer, e.g.
* for stratified sampling use the `group' argument.
* for finite population, use samp.finite
* for time series, use samp.boot.block (block bootstrap)
* for parametric situations, use pbootstrap()
The latter three are in a prerelease bootstrap library, see
www.insightful.com/Hesterberg/bootstrap if you're interested in testing it.

Or, a couple of other possibilities are to use the jackknife
or influence function calculations; these correspond fairly closely
to the Taylor-series linearization that Baskin suggested.

jack <- jackknife(x, exp(mean(log(x))))
inf <- influence(x, exp(mean(log(x))))  # requires the pre-release library
jack
inf

Tim Hesterberg

========================================================
| Tim Hesterberg       Research Scientist              |
| timh@insightful.com  Insightful Corp.                |
| (206)802-2319        1700 Westlake Ave. N, Suite 500 |
| (206)283-6310 (fax)  Seattle, WA 98109-3044, U.S.A.  |
|                      www.insightful.com/Hesterberg   |
========================================================
Formerly known as MathSoft, Insightful Corporation provides analytical
solutions leveraging S-PLUS, StatServer, and Consulting services

<Prev in Thread] Current Thread [Next in Thread>