RE: [R] post hoc kruskal wallis

From: Torsten Hothorn <Torsten.Hothorn_at_rzmail.uni-erlangen.de>
Date: Fri 03 Jun 2005 - 19:14:00 EST

On Thu, 2 Jun 2005, Liaw, Andy wrote:

> By post hoc I guess you meant pairwise comparisons. You might want to check
> out the npmc package on CRAN.
>

?oneway_test in `coin' has an example, essentially

### Length of YOY Gizzard Shad from Kokosing Lake, Ohio,

### sampled in Summer 1984, Hollander & Wolfe (1999), Table 6.3, page 200
YOY <- data.frame(length = c(46, 28, 46, 37, 32, 41, 42, 45, 38, 44,
                             42, 60, 32, 42, 45, 58, 27, 51, 42, 52,
                             38, 33, 26, 25, 28, 28, 26, 27, 27, 27,
                             31, 30, 27, 29, 30, 25, 25, 24, 27, 30),
                  site = factor(c(rep("I", 10), rep("II", 10),
                                  rep("III", 10), rep("IV", 10))))

### Kruskal-Wallis test, approximate exact p-value kw <- kruskal_test(length ~ site, data = YOY,

             distribution = approximate(B = 9999)) kw
pvalue(kw)

### Nemenyi-Damico-Wolfe-Dunn test (joint ranking)
### Hollander & Wolfe (1999), page 244
### (where Steel-Dwass results are given)
if (require(multcomp)) {

    NDWD <- oneway_test(length ~ site, data = YOY,

        ytrafo = function(data) trafo(data, numeric_trafo = rank),
        xtrafo = function(data) trafo(data, factor_trafo = function(x)
            model.matrix(~x - 1) %*% t(contrMat(table(x), "Tukey"))),
        teststat = "maxtype", distribution = approximate(B = 90000))

    ### global p-value
    print(pvalue(NDWD))

    ### sites (I = II) != (III = IV) at alpha = 0.01 (page 244)     print(pvalue(NDWD, adjusted = TRUE)) }

the key step is

xtrafo = function(data) trafo(data, factor_trafo = function(x)

            model.matrix(~x - 1) %*% t(contrMat(table(x), "Tukey")))

where you may specify _any_ contrast matrix, for example just a subset of all pairwise comparisons you are willing to pay for.

Torsten

> Andy
>
> > From: amberfer@ull.es
> >
> > Iīm looking for a program with a post hoc kruskall Wallis
> > test like the Tukey-
> > type non parametric test of ZAR(Biostatistical Analysis
> > 2šEdition). SSPS
> > hasnīt got any non parametric post host test. I donīt know if
> > R has an
> > appropiate post hoc non parametric test. Iīm not sure if NDWD
> > test of the
> > package "coin" is an appropiate test or if the package "npmc"
> > is a best option.
> > Thank you
> >
> >
> > Alfredo Bermúdez
> >
> >
> >
> >
> >
> >
> >
> > -------------------------------------------------
> >
> >
> > ----- Fin del mensaje reenviado -----
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> >
> >
> >
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jun 03 19:19:20 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:22 EST