These are descriptive statistics intended to convey information about price (p
) where "volume" (q
) apparently describes how much was sold at each price.
When dealing with such weights, it's easiest to compute totals first. Adopting hypothetical units of measurement in order to make the numbers concrete, and pretending that all three records are to be summarized (even though they pertain to two different products), suppose the data give volumes in thousands of units sold per month and the prices are in Euros. Then the totals paid in the three months are
Jan product A: 100 K/month * 1 month * 23 Euros = 2300 000 Euros
Jan product B: 11 K/month * 1 month * 45 Euros = 495 000 Euros
Feb product B: 55.7 K/month * 1 month * 60 Euros = 3342 000 Euros
-----------------------------------------------------------------
Total: 6137 000 Euros
The total volume is 100 K/month * 1 month + 11 K/month * 1 month + 55.7 K/month * 1 month = 166.7 K units. Thus, the average price per unit must equal 6137 / 116.7 = 36.81 Euros.
Notice that this is not computed by either the fweights
nor the pweights
options. (In a now-deleted answer, @Penguin_Knight showed us that the unweighted mean is 42.67 and the fweighted
mean is 37.00.)
The standard deviation is similarly computed: the residual prices are (23 - 36.81), (45 - 36.81), and (60 - 36.81). Their weighted mean square is obtained exactly as above: multiply each squared residual by its volume, add them up, and divide by the total volume. The square root of this result, equal to 17.28, is the standard deviation.
These calculations are straightforward to do in Stata or in any statistical software, so I omit the software-specific details.
The weighting options in Stata are wonderful, especially for probability weights, and I have used them: but I never use them without first conducting a detailed check with a calculation like the one here just to make sure I am interpreting the weights correctly. It's usually simple to make such a check by creating a small artificial dataset, most of whose values are zeros. In this way the effect of the weights can immediately be read off the results (and the manual calculations are very easy indeed).