BMJ 1998;316:129 (10 January)

Statistics notes

Weighted comparison of means

J Martin Bland, professor of medical statistics,a Sally M Kerry, lecturer in medical statistics b

a Department of Public Health Sciences, St George's Hospital Medical School, London SW17 0RE, b Division of General Practice and Primary Care, St George's Hospital Medical School, London SW17 0RE

Correspondence to: ProfessorBland

In a recent Statistics Note1 we referred to a weighted two sample t test. Here we describe how it is done. The data were the percentage of requests from general practitioners for x ray examinations which were judged appropriate (table 1), where general practitioners had been randomised to intervention or control groups.2


 
View this table:
[in this window]
[in a new window]
 
Table 1 Number of requests conforming to guidelines for each practice in the intervention and control groups

If we compare the two sets of percentages by the usual two sample t method, each observation (practice) has an equal impact on the result. As some practices contributed fewer requests than others, we wish these practices to have a lesser effect on the estimate of the difference. We can do this by weighting the practices by the number of requests.

To calculate the mean percentage in each group, we simply add the observations together and divide by the number of observations. To calculate the weighted mean, we multiply each observation by the weight, add, then divide by the sum of the weights:


If the weights are all the same this gives the usual, unweighted, mean. Note that the weighted mean, 79.50, is not the same as the unweighted mean in the table, 81.6. There is a slight (but not significant) tendency for general practitioners who make more referrals to have a lower proportion conforming to the guidelines, which explains this. For the second group the weighted mean is 51050/704=72.51.

The weighted standard deviation is found in a similar way. Firstly, we need a weighted sum of squares. To calculate an unweighted sum of squares about the mean, we square and add the observations, then we subtract a correction term, the number of observations times the mean squared. Here we calculate the weighted sum of the observations squared, then subtract the number of observations times the weighted mean squared. For the first group, the weighted sum of the observations squared is:


To get the weighted mean we divided by the sum of the weights; to get a weighted sum we divide by the mean of the weights.) To get the sum of squares about the mean we subtract the correction term, 17x79.502= 107 444.25, giving 109 200.59-107 444.25=1756.34. Dividing this by the degrees of freedom, 17-1=16, gives the weighted estimate of the variance, 1756.34/16=109.77, and the square root is the standard deviation,

For the second group, the weighted sum of the observations squared is 3 751 934/(704/17)=90 600.68 and the sum of squares about the mean is 90 600.68-17x72.512= 1219.78. Hence the estimated variance is 1219.78/ (17-1)=76.24 and the standard deviation

We find the pooled sum of squares by adding the sums of squares within the two groups, 1756.34+1219.78=2976.12 and the common variance estimate for the two groups by dividing by the combined degrees of freedom, 2976.12/(17+17-2) =93.00. We can now use the weighted estimates of the means and common variance in the usual two sample t formulas. The standard error of the difference between the means is

and the difference is 79.50-72.51=6.99. The 95% confidence interval is therefore 6.99-2.04x3.31=0.2 to 6.99+2.04x3.31=13.7. The test of significance is t=6.99/3.31=2.11. With 32 degrees of freedom this gives P=0.04.

For comparison, the unweighted difference is 8.00 and the pooled variance estimate is 157.81. The standard error of the difference is

The 95% confidence interval is -1 to 17 percentage points. In this example the number of requests varies greatly between practices. This must lead to some deviation from the assumptions of the t test, as the variance will not be uniform. The weighted analysis meets the assumptions better and produces a worthwhile reduction in the size of the confidence interval. Some statistical software will do these calculations very simply. The same basic principle is used in meta-analysis to combine studies of varying size.

  1. Kerry SM, Bland JM.Statistics Notes: analysis of a trial randomised in clusters. BMJ 1997;316:54. [Free Full Text]
  2. Oakeshott P, Kerry SM, Williams JE.Randomised controlled trial of the effect of the Royal College of Radiologists' guidelines on general practitioners' referral for radiographic examination. Br J Gen Pract 1994;44:197-200. [Medline]

This article has been cited by other articles:

  • Fredberg, U., Bolvig, L., Andersen, N. T. (2008). Prophylactic Training in Asymptomatic Soccer Players With Ultrasonographic Abnormalities in Achilles and Patellar Tendons: The Danish Super League Study. Am J Sports Med 36: 451-460 [Abstract] [Full text]  
  • Faulkner, K, McCormack, S, Bennison, K (2007). A retrospective analysis of digital stereotaxis in breast screening. Br. J. Radiol. 80: 563-568 [Abstract] [Full text]  
  • Thomas, R., Grimshaw, J., Mollison, J, McClinton, S, McIntosh, E, Deans, H, Repper, J (2003). Cluster randomized trial of a guideline-based open access urological investigation service. Fam Pract 20: 646-654 [Abstract] [Full text]  
  • Chuang, J.-H., Hripcsak, G., Heitjan, D. F. (2002). Design and Analysis of Controlled Trials in Naturally Clustered Environments: Implications for Medical Informatics. J. Am. Med. Inform. Assoc. 9: 230-238 [Abstract] [Full text]  
  • Tai, S. S., Iliffe, S. (2000). Considerations for the design and analysis of experimental studies in physical activity and exercise promotion: advantages of the randomised controlled trial. Br. J. Sports. Med. 34: 220-224 [Full text]  
  • Kerry, S., Oakeshott, P., Dundas, D., Williams, J. (2000). Influence of postal distribution of The Royal College of Radiologists' guidelines, together with feedback on radiological referral rates, on X-ray referrals from general practice: a randomized controlled trial. Fam Pract 17: 46-52 [Abstract] [Full text]  
  • Steptoe, A., Doherty, S., Rink, E., Kerry, S., Kendrick, T., Hilton, S., Day, S. (1999). Behavioural counselling in general practice for the promotion of healthy behaviour among adults at increased risk of coronary heart disease: randomised trial • Commentary: Treatment allocation by the method of minimisation. BMJ 319: 943-948 [Abstract] [Full text]  
  • Kendrick, D., Marsh, P., Fielding, K., Miller, P. (1999). Preventing injuries in children: cluster randomised controlled trial in primary care. BMJ 318: 980-983 [Abstract] [Full text]  
  • Hilton, S., Doherty, S., Kendrick, T., Kerry, S., Rink, E., Steptoe, A. (1999). Promotion of healthy behaviour among adults at increased risk of coronary heart disease in general practice: methodology and baseline data from the Change of Heart study. Health Education Journal 58: 3-16 [Abstract]  

Online poll
Find out more

Rapid responses for this article

There are no rapid responses for this article.


Student BMJ

Risk of surgery for inflammatory bowel disease: record linkage studies

What can you learn from this BMJ paper? Read Leanne Tite's Paper+

www.student.bmj.com

Listen to the latest BMJ Interview