Home page for accesible maths 3.3 Two sample tests

Style control - access keys in brackets

Font (2 3) - + Letter spacing (4 5) - + Word spacing (6 7) - + Line spacing (8 9) - +

3.3.2 Paired data

Suppose that x1,,xn are realisations of IID random variables with Normal(μX,σX2) distribution and y1,,yn are realisations of IID random variables with Normal(μY,σY2) distribution. Assume that the samples are paired and that the population variances are unknown.

Remark.

By assuming paired samples, the random variables within a pair, Xi and Yi are longer independent. To make things easier, we will therefore assume the same covariance for all pairs, i.e. Cov(Xi,Yi)=σXY for i=1,,n.

In the case of paired data, to test the null hypothesis

H0:μX=μY

against any of the alternatives H1:μXμY, H1:μX<μY and H1:μX>μY, we consider the differences D1,,Dn. The above hypothesis can then be rewritten in terms of the population mean μD of the differences,

H0:μD=0

which is tested against H1:μD0, H1:μD<0 and H1:μD>0 respectively.

The algorithm for this test is as follows:

  1. 1.

    Calculate the differences di=xi-yi for i=1,,n.

  2. 2.

    Calculate the sample mean d¯ and sample variance sd2 of the differences d1,,dn.

  3. 3.

    Calculate the test statistic,

    t=d¯sd/n.
  4. 4.

    Compare this to the tn-1-distribution, either by finding a p-value, or by using an appropriate critical value.

TheoremExample 3.3.2 Drug treatment comparison

This example comes from Chapter 6 of Diggle and Chetwynd (2011). They report results on a clinical trial to compare two anti-congestion drugs used to relieve short-term symptoms of asthma: each individual tests both drugs.

In the asthma drug trial, the maximum rate at which the individual was able to exhale, denoted by PEF (Peak Expiratory Flow), was measured a fixed time after administration of each treatment. The following table shows the results for all 13 participants,

Individual (i) 1 2 3 4 5 6 7 8 9 10 11 12 13
Drug F (xi) 310 310 370 410 250 380 330 385 400 410 320 340 220
Drug S (yi) 270 260 300 390 210 350 365 370 310 380 290 260 90
Differences, 40 50 70 20 40 30 -35 15 90 30 30 80 130
(di=xi-yi)

For the two drugs F and S, test the following

H0:μF=μS

vs.

H1:μFμS.
  1. 1.

    This is equivalent to testing

    H0:μD=0

    vs.

    H1:μD0.

    where Di=Xi-Yi.

  2. 2.

    Calculate the differences by subtracting PEF for drug S from PEF for drug F; these are given in the above table.

  3. 3.

    Calculate the sample mean and variance of the differences

    1. d¯=40+50++13013=45.38,

    2. sd2=112i=113(di-45.38)2=1647.8.

  4. 4.

    Find the test statistic

    t=d¯sd/13=45.3840.59/3.61=4.03.
  5. 5.

    The p-value for this, since t>0 and the alternative hypothesis is two-tailed, is

    > 2*(1-pt(4.03,df=12))
    [1] 0.001669197

    that is p=1.67×10-3<0.05, so we would reject H0 at the 5% level and conclude that there is evidence of a difference in the mean PEF between the two drugs.

Remark.

Note that we should always be careful to remove any other which could affect the hypothesis test. In this experiment, administration of the second was separated from administration of the first by a time interval sufficient to ensure that any effects of the first drug have worn off; the order in which the two treatments are given is randomised to remove the potential effect of ordering.