- General Instructions
- The Sign Test
- The Associated Point Estimate (Median)
- The Associated Confidence Interval
- The Zero Fudge

To do each example, just click the "Submit" button. You do not have to type in any R instructions or specify a dataset. That's already done for you.

- Upper-tailed sign test
- Test statistic: B = 21
- Sample size: n = 25
- P-value: P = 0.00046

- Line one assigns the value of the parameter (population median) assumed under the null hypothesis. Usually zero.
- There is no need to sort the z values in line two. It just makes the data easier to look at.
- Alternatives to line five are
1 - pbinom(b - 1, n, 1 / 2) pbinom(n - b, n, 1 / 2)

the first line here does exactly the same as line five in the example, but is less accurate for very small P-values. The second does exactly the same as line five of the example because of the symmetry of the binomial distribution with`p = 1 / 2`

. -
For a
**lower-tailed test**the fifth line would be replaced bypbinom(b, n, 1 / 2)

- For handling zeros see Hollander and Wolfe and the zero fudge section.

- Point Estimate (sample median): 17.6

- Achieved confidence level: 0.9567147
- Confidence interval for the population median: (7.1, 24.7)

- Some experimentation may be needed to achieve the confidence level
you want. The possible confidence levels are shown by
1 - 2 * pbinom(k - 1, n, 1 / 2)

for different values of`k`

. The vectorwise operation of R functions can give them all at oncek <- seq(1, 100) k <- k[1 - 2 * pbinom(k - 1, n, 1 / 2) > 0.5] 1 - 2 * pbinom(k - 1, n, 1 / 2)

If one adds these lines to the form above, one sees that there's not much choice, only three achieved levels0.9854, 0.9567, 0.8922between 0.99 and 0.80. - Alternatively, you can just assign
`k`

to be any integer between zero and`n / 2`

just before the second to last line in the form (`cat . . .`

). A confidence interval with*some*achieved confidence level will be produced. - For a one-tailed confidence interval (called upper and lower bounds by
Hollander and Wolfe) just use
`alpha`

rather than`alpha / 2`

in the fifth line of the form. Then make either the lower limit minus infinity or the upper limit plus infinity, as desired.

Many authorities recommend (at least lukewarmly) the following procedure
for dealing with zero differences (differences equal to the hypothesized
value μ if not zero) in the sign test. After defining the
vector `z`

of differences, do

z <- z[z != mu] n <- length(z)

which treates zero differences as if they were not part of the data (and the sample size is reduced accordingly).

The best that can be said for this is

- Most nonparametrics books recommend it, or at least describe it first.
- From a theoretical point of view, it is a valid test of the hypotheses
H(or the analogous one-sided alternatives).
_{0}: pr(`Z`< μ) = pr(_{i}`Z`> μ)._{i}

H_{1}: pr(`Z`< μ) ≠ pr(_{i}`Z`> μ)._{i}But these hypotheses are

*not what you want to test!*What you want to test is the hypotheses described on p. 60 in Hollander and Wolfe: that the medians are the same or different.Modify the data for our example above for the sign test adding a million zero differences to the data set. The zero fudge says we throw out those zeros and do exactly the same analysis getting

`P`= 0.00046, a highly statistically significant result.But the whole data set says we get

*exactly the same response*in the treatment and control situations in 1,000,000 cases and a different response in only 25 cases. This is overwhelming evidence*in favor of*the null hypothesis (3.37) in Hollander and Wolfe. It is highly significant evidence*against*the tricky null hypothesis of the zero fudge test.**The moral of the story:**In interpreting a test of significance it's not enough that`P`< 0.05. It's even more important*what the null hypothesis is*. Rejecting a null hypothesis of no scientific interest whatsoever is worthless. - Hence the zero fudge is a form of "honest cheating". Widely accepted, but bogus. The reason everyone likes it, of course, is because it produces P < 0.05 more often than the conservative procedure, and everyone likes to get "statistically significant results", even if bogus.

The alternative to the zero fudge, what Hollander and Wolfe call the
*conservative approach* is to count the zero differences as
evidence in favor of the null hypothesis. This is a bit tricky, since
no matter how you do it, the recipe for the test must be altered.

For the lower tailed test, assuming the vector of differences `z`

,
the sample size `n`

, and the hypothesisized value of the median
`mu`

have already been defined,

b <- sum(z >= mu) pbinom(b, n, 1 / 2)

calculates the P-value for the lower-tailed test. Note that we need
the weak inequality (`>=`

) to include the zero differences
in the tail area calculated by the following statement.

Reversing the inquality gives the conservative upper-tailed test.

blow <- sum(z <= mu) pbinom(blow, n, 1 / 2)

Note that this isn't the test statistic described in the book, but obviously does the right thing by symmetry.