Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: kdensity with binned data

From   Amy <>
Subject   st: kdensity with binned data
Date   Sat, 26 Jun 2010 00:45:08 -0700 (PDT)


I have aggregate data for each decile of a population. When I try to 
plot the kernel density estimator (for sake of reference, you can define
 variable "test" to be 10, 20, 40, 50, 60, 70, 80, 90, 95, 99 and then 

kdensity test, kernel(gauss) 

with various bandwidths), its peaks at each of the values are pointed 
rather than smooth. Yet if I try 

histogram test, bin(10) kdensity kdenopts(gauss) 

the density will appear much smoother, even for the same bandwidth and 
kernel. Comparing the results with R's "density(test, 
kernel=c("gaussian"), weights=NULL, window=kernel, n=100)", R's density 
also looks smooth (Stata's "kdensity test, kernel(gauss)" won't let me 
specify n(100) since the number of binned datapoints I have is 10). 
Ultimately I would like to use those 10 binned data points to plot the 
density across the whole population and sample from it so that I can 
infer some values for the person at the 26th percentile, the 27th 
percentile, etc.

Can Stata handle binned data like this?

Thank you.

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index