Galina,
One way to do this would start by using -xtile- to create a variable with the decile of X for each observation.
Then -collapse- X and Y by your decile variable to get the mean of Y and median of X for each of the ten categories.
You can then plot meanY against medianX.
See -help xtile- and -help collapse-.
Hope this helps.
Howie
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Galina Hayes
Sent: Tuesday, February 17, 2009 7:25 PM
To: [email protected]
Subject: st: categorising continuous variable and generating mean outcome
Evening all,
I am sure there is a very simple solution to this but it has me foxed. I have two variables, Y coded as (0,1) and X which is continous. I want to break x down into 10 equal size categories (by range or percentiles, doesn't matter) and generate the mean of Y for each of the 10 categories (call it meanY) and then plot meanY against the centre value of each X category. Does this make sense? Seems like it should be easy,
Thanks
Galina
*
* 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/
*
* 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/