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

# st: kdensity with few (/aggregated) data points

 From Amy To statalist@hsphsun2.harvard.edu Subject st: kdensity with few (/aggregated) data points Date Wed, 30 Jun 2010 08:23:11 -0700 (PDT)

```Hi,

I just thought to re-phrase my question. I've noticed that if I have very few data points (e.g. 10) then kdensity gives me something jagged even if I specify a Gaussian kernel (regardless of the bandwidth). If the reason I have so few data points is because I have aggregate data, e.g. data for each decile of a population, is there any way to make this smoother? Why is it that histogram X, bin(10) kdensity kdenopts(gauss) will give me something that looks smoother?

Thank you.

--- On Sat, 6/26/10, Amy <dartmouthemails@yahoo.com> wrote:

> From: Amy <dartmouthemails@yahoo.com>
> Subject: kdensity with binned data
> To: statalist@hsphsun2.harvard.edu
> Date: Saturday, June 26, 2010, 3:45 AM
> Hi,
>
> 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
> try
>
> 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:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```