Pages

Friday, October 09, 2009

Random Stata tip

Sometimes you want to compare 2 densities, say for 2 sub-populations. I came across some code years ago for this which was a bit clumsy and then I lost the code so I worked out a better way.

You have a continuous variable Y and a dummy variable male=1,0 . You want to compare the male & female densities

Kdensity Y if male==1, addplot (kdensity Y if male==0)

Of course you knew this already

No comments:

Post a Comment