From edd at debian.org  Wed Oct 15 01:38:32 2003
From: edd at debian.org (Dirk Eddelbuettel)
Date: Wed Oct 15 01:37:40 2003
Subject: [Rd] fivenum (PR#4586)
In-Reply-To: <200310142320.h9ENK40P013349@pubhealth.ku.dk>
References: <200310142320.h9ENK40P013349@pubhealth.ku.dk>
Message-ID: <20031014233832.GA8506@sonny.eddelbuettel.com>

On Wed, Oct 15, 2003 at 01:20:04AM +0200, r.huggins@latrobe.edu.au wrote:
> Full_Name: Richard Huggins
> Version: 1.7.1
> OS: windows 2000
> Submission from: (NULL) (131.172.4.44)
> 
> 
> > x<-rnorm(100,2,1)
> > mean(x)
> [1] 1.73299
> > summary(fivenum(x))
>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
> -0.3655  1.1070  1.7430  1.7320  2.3840  3.7910 
> > summary(x)
>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
> -0.3655  1.1070  1.7430  1.7330  2.3830  3.7910 
> > y<-log(abs(x))
> > summary(fivenum(y))
>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
> -3.5950  0.1020  0.5555 -0.1472  0.8688  1.3330 
> > mean(y)
> [1] 0.2878568
> > summary(y)
>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
> -3.5950  0.1021  0.5555  0.2879  0.8683  1.3330 
> 
> 
> summary(fivenum(x)) gives the wrong mean

I think you may be misunderstanding what is happening -- fivenum() returns a
simple vector of five numbers, which summary then summarises. 

It so happens that for an (approx.) symmetrically distributed sample x as
the one you drew from the N(2,1), mean(summary(x)) is still approx. mean(x)
(and identical asymptocally).  That no longer holds once you take
logs(abs()).  As so often, it helps to simply plot the data as you could with

> boxplot(x,summary(x),fivenum(x),y,summary(y),fivenum(y),horizontal=TRUE)


Hth, Dirk



-- 
Those are my principles, and if you don't like them... well, I have others.
                                                -- Groucho Marx


[Rd] fivenum (PR#4586)
Dirk Eddelbuettel