Biology, images, analysis, design...
|"It has long been an axiom of mine that the little things are infinitely the most important" |
Two-sample t-testOn this page: Equal variance t-test Unequal variance t-test t-tests for cross-over Weighted t-test
1. Equal variance t-test
This example uses hypothetical data on the effect of drug treatment on the length of time from treatment to lambing. It is based on a trial of the efficacy of dexamethasone to induce parturition in
We first look at the distributions for the each group of observations, shown in the plots below. The distributions deviate from normality both for raw and transformed data. We will therefore postpone a decision on whether to transform until we have tested for equality of variances - but remember that the F-ratio test will not be very reliable for this, since it is sensitive to departures from normality.
We first carry out an F-ratio test on the variances of the untransformed data:
Since the above result is highly significant, we carry out the same test on the variances of the log transformed data:
The test on the transformed data gives a borderline but non-significant P-value. Since with skewed distributions the F-ratio test is too liberal in reporting
Hence we proceed with a equal variance t-test on the log transformed data. Since our sample sizes are neither equal nor large, we use the general
The 95% normal approximation confidence interval around the (transformed) treatment effect is obtained as follows, and then detransformed to give the ratio (control/treated) of the geometric means:
95% CI = 0.200 ± (2.145 × 0.0672) = 0.056 to 0.344 (transformed scale)
Ratio = 1.58 (95% CI 1.138 to 2.208) (detransformed scale)
We can conclude that the parturition time of untreated animals was on average 1.6 times (95% CI: 1.4 to 2.1) that of untreated animals. However, the small number of animals in the control group and the uncertainty over whether allocation was random means we cannot have much confidence in this result. The experiment should ideally be repeated with random allocation to similarly sized treatment groups.
2. Unequal variance t-test
Rather than transform the data above on the effect of drug treatment on the length of time from treatment, one might have been tempted to use the unequal variance
Published statistical tables reveal the P-value for t' = 2.3069 at 4 degrees of freedom is 0.0823. Hence the difference is not significant at the 5% level. We would get the same answer using
The 95% normal approximation confidence interval around the (non-significant) treatment effect is obtained as follows:
95% CI = 35.273 ± (2.665 × 15.2903) = −5.46 to 76.01
We would therefore conclude from using the unequal variance test that we have no evidence of a difference between treatments for the time from treatment to lambing. In other words the opposite conclusion to that we reached when we used an equal variance t-test on log transformed data. The main reason for the apparent contradiction is that the unequal variance t-test can be very conservative if sample sizes in each group differ greatly. Transformation followed by an equal variance test is usually preferable providing a suitable variance stabilising transform can be found.
3. Use of t-tests for a cross-over design
We looked at the cross-over design in
This example uses data gathered in a trial of two drugs used for pain relief for arthritis patients. Subjects were randomly allocated to two sequence groups. A sequence group is characterized by the order in which treatments are given. All subjects in sequence group (1) received treatment A1 followed later by treatment A2. All subjects in sequence group (2) received treatment A2 followed by treatment A1. The response variable was the level of pain experienced.
We first display the results graphically. The two top figures below follow what happens to individual subjects through the trial. Irrespective of which order the drugs are given in, the pain score is lower when patients are on treatment A2 than when on A1.
The lower figure shows mean responses. These suggest a slight period effect - pain levels decrease from period 1 to period 2 - but it appears to affect both drugs similarly. In other words there is probably no period × treatment interaction. If there were an interaction, then the lines in the last figure would no longer be parallel and we could not analyse the data as a single cross-over experiment. To understand why this is so, and how to test these results, let us rearrange these means and their
If we exclude random variation, the differences between these 4 means are due to a combination of the treatment effect, T, and period effect P.
In which case we would expect that
Let us check for any interaction between time period and treatment (in other words if the relative efficacy of the two treatments is dependent on time period) by comparing the mean of the totals (A1+A2) of the two sequence groups.
The mean of the subject totals for Group 1 = [58 + 60 + 71 + 73]/4 =
Again provided P and T do not interact, excluding random variation, we would expect that:
Therefore, the estimated treatment effect, T, is
The mean difference for period 1 to period 2 for group 1 (d1)
The 95% normal approximation confidence interval around the treatment effect is obtained as follows:
4. The weighted t-test
Trials of vector control methods are often carried out using cluster randomization because the effects of treatment tend to act at the group rather than individual level. We will take a hypothetical example of a trial of insecticide impregnated bed nets targeted at Anopheles mosquitoes for control of malaria. Ten villages are included in the trial. Five are allocated at random to receive a bed net intervention. The outcome variable is the prevalence of malaria parasites in children aged 1-5 years. There are a different number of eligible children in each village so a weighted analysis is required.
The weighted means are markedly different from the unweighted means, with a larger apparent treatment effect. This is mainly because the two largest villages in the control group had higher prevalences than the
Since the F-ratio for these two variances is not significant, we can use the equal variance t-test. This gives a t-value of 3.851 with 8 degrees of freedom (P = 0.005). The mean difference between prevalences is 21.4% (95% CI 8.6 to 34.2).
If we had ignored the different sample sizes we would still have found no significant difference between the variances, and proceeded with an unweighted equal variance t-test. This would have given a t-value of 2.241 for which P = 0.055, in other words not quite significant at the conventional P = 0.05 level.