Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Standard error of the weighted mean

From   nick bungy <>
To   "" <>
Subject   st: Standard error of the weighted mean
Date   Fri, 3 May 2013 18:03:57 +0100

Dear Statalist,

I am having issue finding the correct way to calculate the standard error of a probability weighted mean. I can successfully calculate the sample standard deviation, as taken from:
s2 = {n/[W(n - 1)]} sum wi (xi - xbar)2
The Stata article suggests that the standard error of the weighted mean is then simply:
V_srs = s2/n
Where V_srs is an ‘estimate of the variance of muhat [mean] assuming a simple random sample of the same number of observations’
However, when I calculate V_srs and compare it to the linearized standard error as taken from the svy: commands, the linearized standard error is significantly larger.
Since my calculations and Stata agree on s^2, presumably I must be calculating V_srs (variance of the mean) incorrectly.
Can anyone shed some light on where I am going wrong? Here's an example of the disparity between my mata code and the official svy command.
sysuse auto
gen pweight = trunk^2 + 1
st_view(y=. ,. , "mpg")
st_view(weight =. ,., "pweight")
Weighted_mean = colsum(y:*weight) / colsum(weight)
Weighted_var = rows(y)/(colsum(weight)*(rows(y)-1))*colsum(weight:*(y :- Weighted_mean):^2)
Weighted_sd = sqrt(Weighted_var)
SD_Mean = sqrt(Weighted_var / rows(y))
svyset [pweight = pweight]
svy: mean mpg
estat sd
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index