[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: differences between kdensity plots

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: differences between kdensity plots
Date   Wed, 30 Jan 2008 14:20:25 -0000

Fond though I am of density estimation, I would be a little queasy about
this. There are several little choices, in terms of which kernel, which
bandwidth, which mesh of points is used for storing estimates, etc., and
as you end up calculating a difference, small quirks might be magnified.

I trust Rich is also considering other graphical handles on comparing
his distributions, including quantile-quantile plots, and variants on
them discussed in 

Stata tip 47: Quantile-quantile plots without programming. 
SJ 7(2):275--279 

And also -stripplot- from SSC which offers various ways to show the raw

Incidentally, see -range- as an alternative to the -generate- statement
here in Austin's code. 

[email protected] 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Austin
Sent: 29 January 2008 21:59
To: [email protected]
Subject: Re: st: differences between kdensity plots

Richard Goldstein <[email protected]>:

I would not use twoway__kdensity_gen which is for histogram bins.
Instead use the at() and gen() options on kdensity like so:

sysuse auto, clear
su mpg, meanonly
g x=r(min)+(_n-1)*(r(max)-r(min))/50 in 1/51
kdensity mpg if for==0, at(x) g(d) nogr
kdensity mpg if for==1, at(x) g(f) nogr
g diff=f-d
line d f x, name(compare)
line diff x, name(diff)

On Jan 29, 2008 4:43 PM, Richard Goldstein <[email protected]>
> I have produced a graph with two kdensity plots on it (one for the age
> of each of two groups of people) -- I am now interested in producing
> some statistics about the difference(s) between these plots; I have
> never thought about this issue before and wonder if there are any
> "standard" or common differences that are used to describe (or even to
> test) the differences between the two plots.
> Note that I assume I can use the undocumented twoway__kdensity_gen
> command to obtain the data underlying each plot. If anyone has used
> and thinks I am wrong in my reading of the help file, please tell me.
> Note also that there may well be numerous kinds of differences and I
> don't wish to eliminate any possibilities at this time.
*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index