Statalist The Stata Listserver


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

frequency polygons [was: RE: st: Using gen / egen in one step (not two)]


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   frequency polygons [was: RE: st: Using gen / egen in one step (not two)]
Date   Sun, 7 Jan 2007 19:13:16 -0000

Marcello mentions -eqprhistogram-, which is a program on SSC. 

A search using -findit- reveals nothing. Various people 
have played with this in this past, but none that I know 
of got as far as a truly general program which they made 
public. 

This is (now) either fairly easy or a little more difficult. The 
easiest case is when your bins are such that there are 
no bins other than those beyond the extremes with zero
frequencies. The more difficult case is when you need
to cope with zero bins in the middle of the distribution. 

The "(now)" qualifier reflects the existence of -twoway__histogram_gen-
discussed by David Harrison in SJ 5(2) 2005. 

The following shows some technique but falls far short of 
a general recipe. 

sysuse auto, clear 
twoway__histogram_gen mpg, start(0) width(2) freq gen(mpgfreq mpgbin)
levelsof mpgbin, local(have)
numlist "11(2)43"
local should "`r(numlist)'"
local need : list should - have 
local i = _N
qui foreach v of local need {
	replace mpgbin = `v' in `i'
	replace mpgfreq = 0 in `i'
	local --i
}
twoway line mpgfreq mpgbin, sort

Nick 
[email protected] 

Marcello Pagano
 
> Do we have a frequency polygon in Stata?  On top of eqprhistogram?

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index