The formula is
f(x) = {1/(h*W} {sigma [wi * K((x - xi)/h)]}
where wi are the weights (inverse of sampling probability
if the weights are sampling weights) and W is the sum of
weights over all observarions and
. kdensity income [aw=MY_W]
will give you the correct estimate.
ben
Also see:
- http://fmwww.bc.edu/RePEc/bocode/k/kdens.pdf.
- Buskirk and Lohr (2005). Asymptotic properties of kernel
density estimation with complex survey data. Journal
of Statistical Planning and Inference 128: 165 - 190.
Vora N wrote:
> I have problem understanding the aweight option
> in kdensity command and the manual (and everywhere
> else I have read) is not helping. Please help?
> Also, please correct me if my understanding is wrong.
>
> Basically, if I have a survey data of people's income
> in a country. Let's say I have n observation in
> my data and each observation has its own weight
> (sampling weight -- I believe it's called probability
> weight in stata?). These weights will sum to the country's
> population. This weight variable is named MY_w.
> (sum of MY_w over all the n observations equals to the
> country's population)
>
> Now, I want to estimate the density of their income.
>
> --------------------
> if I do:
>
> >kdensity income
>
> Then, I don't take into account of those sampling
> weights. The formula is:
>
> [equation 1]
> f(x) = {1/nh} {sigma[(K(x - xi)/h)]}
>
> h--bandwidth
> n--sample size
> K--kernal function
> xi--each observation's income
> sigma--summation i = 1 to n
>
> So I assume that each observation is sampled at equal
> probability of 1/n -- which is wrong?
>
> --------------------
> I think the weight I have is pweight but kdensity
> doesn't allow pweight. It only allows fweight and
> aweight. It seems like fweight is out of the question.
>
> I should be doing this?
>
> [equation 2]
> f(x) = {1/h} {sigma [wi * K((x - xi)/h)]}
>
> where wi is the probability of that observation being
> sampled (so wi was 1/n in [equation 1])
>
> Now, I wonder if kdensity with aweight can give me
> the estimate of [equation 2]
>
> Should I be doing this?
>
> >kdensity income [aw=MY_W]
>
> or should I be doing this?
>
> >kdensity income [aw=1/MY_W]
>
> or I shouldn't use aweight and try to edit the command
> by my owen? Would the unweighted version be wrong?
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/