# How to explain wilcox.test strange result example?

I am using R to do below test:

hsb2 <- within(read.csv("https://stats.idre.ucla.edu/stat/data/hsb2.csv"), {
race <- as.factor(race)
schtyp <- as.factor(schtyp)
prog <- as.factor(prog)})


Then,

>wilcox.test(hsb2$write,mu=52) Wilcoxon signed rank test with continuity correction data: hsb2$write
V = 9503.5, p-value = 0.2164
alternative hypothesis: true location is not equal to 52


Will you accept this 52 result?

>median(hsb2$write) [1] 54 > wilcox.test(hsb2$write,mu=54)

Wilcoxon signed rank test with continuity correction

data:  hsb2$write V = 7472, p-value = 0.1869 alternative hypothesis: true location is not equal to 54  p-value of 54<52?? > wilcox.test(hsb2$write,mu=53)

Wilcoxon signed rank test with continuity correction

data:  hsb2$write V = 10060, p-value = 0.8927 alternative hypothesis: true location is not equal to 53  52 or 53 or 54? How to trust wilcox.test()? • The pseudomedian is 53 (and so the estimate of the location that the test uses) -- the test will not reject values in the vicinity of that, just as a t-test doesn't reject a range of values in the vicinity of the sample mean (try the one sample t-test on mu=52, 53 and 54)... Jul 10, 2017 at 8:23 • At least, t test's p-value is bigger when closer to mean Jul 10, 2017 at 8:46 • The equivalent is true for the Wilcoxon test. (the p-value is bigger when you get closer to the pseudomedian). Jul 10, 2017 at 9:35 • wilcox.test(hsb2$write, conf.int=TRUE) gives a point estimate & confidence interval for the pseudomedian. Jul 10, 2017 at 9:49

I can't see a problem here.

First, you get large p-value (>0.05) for mu=52, so you may conclude that there is no evidence that location is not 52. Test doesn't say "median is 52", it says "you do not have evidence that it is not". And since sample median is 54 and sample is not very large ($n=41$), it is exactly what I would expect.

Remember, you can not accept H0 (which says "median is equal to mu"), you only can reject it or conclude that you don't have evidence to do this. So

52 or 53 or 54?

is not an appropriate question for Wilcoxon (or any other) test. You can ask "Can I throw 52 away?". And test says "No". The same is with 53 and 54.

• (+1) You could go on to note that the set of hypothesized values for $\mu$ that you can't reject at a 5% significance level form a 95% confidence interval for $\mu$. Jul 10, 2017 at 8:09
• Maybe the OP is asking why the p-value for 54 is less than 52 (or 53) even though the sample median is 54? Jul 10, 2017 at 8:22
• @user43849: you're right - "p-value of 54<52??" was buried rather. Jul 10, 2017 at 9:50