Jump to: Page Content, Site Navigation, Site Search,
You are seeing this message because your web browser does not support basic web standards. Find out more about why this message is appearing and what you can do to make your experience on this site better.
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
|
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,
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
For comparison, the unweighted difference is 8.00 and the pooled variance estimate is 157.81. The standard error of the difference is
What can you learn from this BMJ paper? Read Leanne Tite's Paper+