Consider the following permutation test for the two-sample problem with
hypotheses \((4.9 .7) .\) Let \(\mathbf{x}^{\prime}=\left(x_{1}, x_{2}, \ldots,
x_{n_{1}}\right)\) and \(\mathbf{y}^{\prime}=\left(y_{1}, y_{2}, \ldots,
y_{n_{2}}\right)\) be the
realizations of the two random samples. The test statistic is the difference
in sample means \(\bar{y}-\bar{x} .\) The estimated \(p\) -value of the test is
calculated as follows:
1\. Combine the data into one sample
\(\mathbf{z}^{\prime}=\left(\mathbf{x}^{\prime}, \mathbf{y}^{\prime}\right)\).
2\. Obtain all possible samples of size \(n_{1}\) drawn without replacement from
\(\mathrm{z}\). Each such sample automatically gives another sample of size
\(n_{2}\), i.e., all elements of \(\mathbf{z}\) not in the sample of size \(n_{1}\).
There are \(M=\left(\begin{array}{c}n_{1}+n_{2} \\ n_{1}\end{array}\right)\)
such samples.
3\. For each such sample \(j\) :
(a) Label the sample of size \(n_{1}\) by \(\mathbf{x}^{*}\) and label the sample
of size \(n_{2}\) by \(\mathbf{y}^{*}\).
(b) Calculate \(v_{j}^{*}=\bar{y}^{*}-\bar{x}^{*}\).
4\. The estimated \(p\) -value is \(\hat{p}^{*}=\\#\left\\{v_{j}^{*} \geq
\bar{y}-\bar{x}\right\\} / M\).
(a) Suppose we have two samples each of size 3 which result in the
realizations:
\(\mathbf{x}^{\prime}=(10,15,21)\) and \(\mathbf{y}^{\prime}=(20,25,30)\).
Determine the test statistic and the permutation test described above along
with the \(p\) -value.
(b) If we ignore distinct samples, then we can approximate the permutation
test by using the bootstrap algorithm with resampling performed at random and
without replacement. Modify the bootstrap program boottesttwo.s to do this and
obtain this approximate permutation test based on 3000 resamples for the data
of Example \(4.9 .2 .\)
(c) In general, what is the probability of having distinct samples in the
approximate permutation test described in the last part? Assume that the
original data are distinct values.