[R] Wilcoxon nonparametric p-values
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Tue May 19 16:33:05 CEST 2009
Charles Van deZande wrote:
> Thanks Peter,
> There are 8 measurements less than 8.5, so calculating the probability
> (binomial) of 8, or fewer, happening by chance with n = 20 and p = 0.50
> gives P = 0.25-- the book answer. I've tried several problems in other
> textbooks and in each case I get vastly different P-values than I get
> with wilcox.test or wilcox.exact.
Ah, but that is NOT a signed-rank test, just a sign test. (Using the
former as a test of the median is BTW not really a good idea unless you
assume symmetry of the distribution.)
It is also still a one-sided test, with two tails you get
> binom.test(8,20)
Exact binomial test
data: 8 and 20
number of successes = 8, number of trials = 20, p-value = 0.5034
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
0.1911901 0.6394574
sample estimates:
probability of success
0.4
(and that is disregarding that one observation is exactly 8.5, so you
should really look at 7 in 19 rather than 8 in 20.)
> However, upon further testing, I've found good agreement when the
> calculated P-values are small, but disagreement when P-values are
> large. This might mean a problem with wilcox.test and wilcox.exact when
> P-values are large or I might be misinterpreting something.
You need to read some more theory.
The extreme cases (all signs equal) are equally unlikely for the sign
test and the signed-rank test.
> CHV
>
> Charles H Van deZande
> /-------Original Message-------/
>
> /*From:*/ Peter Dalgaard <mailto:p.dalgaard at biostat.ku.dk>
> /*Date:*/ 5/19/2009 5:35:07 AM
> /*To:*/ cvandy <mailto:cvandy26 at gmail.com>
> /*Cc:*/ r-help at r-project.org <mailto:r-help at r-project.org>
> /*Subject:*/ Re: [R] Wilcoxon nonparametric p-values
>
> cvandy wrote:
> > When I use wilcox.test, I get vastly different p-values than the problems
> > from Statistics textbooks.
> > For example:
> > The following problem comes from "Applied Statistics and Probability for
> > Engineers", 2nd Edition, by D. C. Montgomery. Page736, problem
> 14.7. The
> > problem is to compare the sample data with a population median of
> 8.5. The
> > book answer is p = 0.25, wilcox.test answer is p = 0.573.
> > I've tried several other similar problems with similar results. I've
> copied
> > the following directly from my workspace.
>
> wilcox.exact (from exactRankTests) gives
>
> > wilcox.exact(x - 8.5)
>
> Exact Wilcoxon signed rank test
>
> data: x - 8.5
> V = 80.5, p-value = 0.5748
>
> so I'd suspect the textbook. One-sided p-value perhaps? or table
> limitation (as in "p > .25"). If you want to dig deeper, you'll probably
> have to check the computations implied by the text.
>
> > Thanks for any help,
> > CHV
> >> x<-c(8.32,8.05,
> >>
> 8.93,8.65,8.25,8.46,8.52,8.35,8.36,8.41,8.42,8.30,8.71,8.75,8.6,8.83,8.5,8.38,8.29,8.46)
> >> wilcox.test(x,y=NULL,mu=8.5)
> > Wilcoxon signed rank test with continuity correction
> > data: x
> > V = 80.5, p-value = 0.573
> > alternative hypothesis: true location is not equal to 8.5
> >
> > Warning messages:
> > 1: In wilcox.test.default(x, y = NULL, mu = 8.5) :
> > cannot compute exact p-value with ties
> > 2: In wilcox.test.default(x, y = NULL, mu = 8.5) :
> > cannot compute exact p-value with zeroes
> >
> > Charles H Van deZande
> >
> >
> >
> >
> >
> >
>
>
> --
> O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
> c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
> (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk
> <mailto:p.dalgaard at biostat.ku.dk>) FAX: (+45) 35327907
>
>
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list