InfluentialPoints.com Biology, images, analysis, design... 

"It has long been an axiom of mine that the little things are infinitely the most important" 

Twosample ttestOn this page: Equal variance ttest Unequal variance ttest ttests for crossover Weighted ttest1. Equal variance ttestWorked exampleThis 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 Fratio test will not be very reliable for this, since it is sensitive to departures from normality. We first carry out an Fratio 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 nonsignificant Pvalue. Since with skewed distributions the Fratio test is too liberal in reporting
Hence we proceed with a equal variance ttest on the log transformed data. Since our sample sizes are neither equal nor large, we use the general
For a twotailed test with a tstatistic of 2.984 with 14 degrees of freedom, 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 ttestWorked exampleRather 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
Then we use
Published statistical tables reveal the Pvalue 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 (nonsignificant) 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 ttest on log transformed data. The main reason for the apparent contradiction is that the unequal variance ttest 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 ttests for a crossover designWorked exampleWe looked at the crossover 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 A_{1} followed later by treatment A_{2}. All subjects in sequence group (2) received treatment A_{2} followed by treatment A_{1}. 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 A_{2} than when on A_{1}. 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 crossover 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 (A_{1}+A_{2}) 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 (d_{1}) The 95% normal approximation confidence interval around the treatment effect is obtained as follows: 95% CI = 17.8 ± 0.5 × 2.447 × 2.843 = 14.3 to
We checked for a period effect, P, by assessing
4. The weighted ttestWorked exampleTrials 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 15 years. There are a different number of eligible children in each village so a weighted analysis is required.
We first estimate the weighted mean prevalence of each treatment 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 Using
We then calculate the weighted variance of each treatment
Since the Fratio for these two variances is not significant, we can use the equal variance ttest. This gives a tvalue 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 ttest. This would have given a tvalue of 2.241 for which P = 0.055, in other words not quite significant at the conventional P = 0.05 level.
