From p.dalgaard at biostat.ku.dk  Mon Apr  5 14:28:52 2004
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Mon Apr  5 14:31:13 2004
Subject: [Rd] fligner.test (ctest) (PR#6739)
In-Reply-To: <20040405121300.6693A1046B@slim.kubism.ku.dk>
References: <20040405121300.6693A1046B@slim.kubism.ku.dk>
Message-ID: <x2smfiip6j.fsf@biostat.ku.dk>

karel.zvara@mff.cuni.cz writes:

> Full_Name: Karel Zvara
> Version: 1.8.1
> OS: MS Winows 2000
> Submission from: (NULL) (195.113.30.163)
> 
> 
> The test statistics of the fligner.test (ctest package) depends on the order of
> cases:
> 
> > fligner.test(count~spray,data=InsectSprays)
> 
>         Fligner-Killeen test for homogeneity of variances
> 
> data:  count by spray 
> Fligner-Killeen:med chi-squared = 14.4828, df = 5, p-value =
> 0.01282
> 
> > fligner.test(count~spray,data=InsectSprays[order(InsectSprays$count),])
> 
>         Fligner-Killeen test for homogeneity of variances
> 
> data:  count by spray 
> Fligner-Killeen:med chi-squared = 5.4527, df = 5, p-value =
> 0.3632
> 
> > fligner.test(count~spray,data=InsectSprays[order(sample(72)),])
> 
>         Fligner-Killeen test for homogeneity of variances
> 
> data:  count by spray 
> Fligner-Killeen:med chi-squared = 2.7349, df = 5, p-value =
> 0.7408
> 
> The problem lies, I think, in the ordering of centered values x:
> 
>  x <- unlist(tapply(x, g, function(u) u - median(u)))

Right. x is not in the same order as g is after that operation, so
the two lines that come immediately after are incoherent:

    a <- qnorm((1 + rank(abs(x))/(n + 1))/2)
    STATISTIC <- sum(tapply(a, g, "sum")^2/tapply(a, g, "length"))


I think the unlist construction wants to be replaced with

  x <- x - tapply(x,g,median)[g]



-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907


[Rd] fligner.test (ctest) (PR#6739)
Peter Dalgaard