Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Multiple density plots, rotated and distributed on x-axis
From
Scott Merryman <[email protected]>
To
[email protected]
Subject
Re: st: Multiple density plots, rotated and distributed on x-axis
Date
Tue, 2 Aug 2011 12:55:48 -0500
Like this?
clear
sysuse auto
set obs 5000
kdensity mpg if fore == 0, n(5000) k(gauss) bw(3) gen(h0 d0)
line d0 h0
kdensity mpg if fore == 1, n(5000) k(gauss) bw(3) gen(h1 d1)
replace d1 = d1 + .2
tabstat mpg, by(fore) stat(p25 p50 p75) nototal
line h1 d1 || line h0 d0, xtitle("") xlabel( .02 "Domestic" .22
"Foreign" ) ///
legend(off) scheme(lean1) ///
|| scatteri 24.5 .264 19 .077 , recast(connected) ms(O) lw(thin) ///
|| scatteri 21 .255 16.5 .0698 , recast(connected) ms(O) lw(thin) ///
|| scatteri 28 .2427 22 .0601 , recast(connected) ms(O) lw(thin)
Scott
On Mon, Aug 1, 2011 at 1:26 PM, Venable <[email protected]> wrote:
> Dear Statalist,
>
> I would like to create a graph that contains several kernel density
> plots, but with the plot rotated 90% right from the usual orientation,
> and with each plot aligned to a point on the x axis.
>
> To be more concrete (borrowing an example from Angrist and Pischke,
> Mostly Harmless Econometrics, Figure 3.1.1), suppose I wanted to show
> the distribution of incomes in the US at different levels of eduction,
> e.g. 8 years, 12 years, 14, 16, etc. The x-axis of the graph would be
> years of education and the y axis the level of income. Above each
> year, there would be a kernel density plot of incomes for that year,
> with each rotated to the right, so that the "height" (density) is
> horizontal distance.
>
> An additional bonus would be to be able to mark a few quantiles on
> each density and connect these between years. For example, mark the
> 25th, median and 75th percentile for each year and have these points
> connected.
>
> Is this possible in Stata?
>
> I fear I may not be explaining this well in words, in spite of the
> fact that it is very easy to show as a picture. Unfortunately Figure
> 3.1.1 is not available in the Google Preview version of Mostly
> Harmless Econometrics, so I have posted a simple hand-drawn version
> here:
>
> http://dl.dropbox.com/u/2937392/density-plot-sketch.pdf
>
*
* 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/