[R] - Nonparametric variance test

(Ted Harding) ted.harding at nessie.mcc.ac.uk
Mon Mar 5 01:49:59 CET 2007


On 04-Mar-07 Bernd Dittmann wrote:
> Hi useRs,
> 
> can a variance test for 2 non-normal samples be tested in R? Also, thus
> far I have not been able to find the Friedman two way analysis of
> variance.
> 
> For normal r.v., the var.test is available, but are there any tests 
> available for non-normal samples?
> 
> Thanks!
> 
> Bernd

If you are seeking to test whether two samples have equal "variances",
you might like to consider Tukey's "hijack" of the Mann-Whitney test.

First, relocate one sample so that both have the same median (NOTE
that there may be an implicit assumption here).

Next, pool the samples (retaining identity), just as in Mann-Whitney.
Suppose the result for two samples X and Y (in increasing order) looks
like

  X X Y X Y X X Y Y Y X X Y X Y Y Y Y X Y X X Y X X X  [**]

  A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

where the second row of letters is used as labels.

Then read off the identities of the elements alternately from the
two ends of [**], from the outside in:

  A Z B Y C X D W E V F U G T H S I R J Q K P L O M N

leading to

  X X X X Y X X Y Y X X X X Y Y X Y Y Y Y X Y X Y Y X

and then do a Wilcoxon test (equivalent to Mann-Whitney) on the
result.

Here you may as well allocate the final sequence of X and Y terms
the values 1,2,3,...,26 from left to right:

  X
  [1]  1  2  3  4  6  7 10 11 12 13 16 21 23 26
  Y
  [1]  5  8  9 14 15 17 18 19 20 22 24 25


and then wilcox.test() gives the result

  wilcox.test(x=X,Y)
        Wilcoxon rank sum test
  data:  X and Y

  W = 50, p-value = 0.08493
  alternative hypothesis: true mu is not equal to 0 


What this is really testing is whether the X values lie closer
to, or further from, their median than the Y values do relative
to their median. Using the default two-sided alternative, the
P-value is then 0.08493; if you already expected that any difference
would be in the direction of Y closer to median than X, for instance,
then

  wilcox.test(X,Y,alternative="less")
        Wilcoxon rank sum test
  data:  X and Y 

  W = 50, p-value = 0.04246
  alternative hypothesis: true mu is less than 0 

since "less" means that the X's tend to occur earlier in the
sequence [**] than the Y's (i.e. tend to occur nearer the ends).

Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 05-Mar-07                                       Time: 00:49:43
------------------------------ XFMail ------------------------------



More information about the R-help mailing list