Statalist The Stata Listserver


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

st: RE: Including kdensity graph into a histogram with frequencies


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Including kdensity graph into a histogram with frequencies
Date   Thu, 20 Jul 2006 22:50:47 +0100

Given frequencies in bins of given width, the comparable 
frequency density is, I think, 

sample size * probability density * bin width 

So, you should specify bin width when doing the histogram
and superimpose an equivalent curve generated by -kdensity- 
or one of its Ben Jann clones. 

Checking especially welcome. 

Nick 
n.j.cox@durham.ac.uk 

Daniel Schneider
 
> I have been trying to combine a kdensity graph and a histogram of the
> same distribution, but I would like to have the axis for the histogram
> in frequencies, not densities. I have experimented with using 
> individual
> axes for both the histogram and the density line, but then the two
> results don't match anymore. 
> 
> Here is a command I have been using:
> 
> _kdens variable ,kernel(triangle) ll(0) gen(y x)
> twoway (hist variable ,freq ) (line x y ,lcolor(black) lstyle(solid)
> yaxis(2) ytitle("",axis(2)) ylabel(none,axis(2))  ) , legend(off) 
> 
> 
> Is there any solution for this problem? Using density and 
> "faking" (i.e.
> relabeling) the axis for the histogram?

*
*   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/



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