[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Howard Lempel <HLempel@brookings.edu> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: categorising continuous variable and generating mean outcome |

Date |
Tue, 17 Feb 2009 19:36:20 -0500 |

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: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Galina Hayes Sent: Tuesday, February 17, 2009 7:25 PM To: statalist@hsphsun2.harvard.edu 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/

**Follow-Ups**:**Re: st: RE: categorising continuous variable and generating mean outcome***From:*Galina Hayes <galina@uoguelph.ca>

**References**:**st: categorising continuous variable and generating mean outcome***From:*Galina Hayes <galina@uoguelph.ca>

- Prev by Date:
**st: categorising continuous variable and generating mean outcome** - Next by Date:
**Re: st: RE: categorising continuous variable and generating mean outcome** - Previous by thread:
**st: categorising continuous variable and generating mean outcome** - Next by thread:
**Re: st: RE: categorising continuous variable and generating mean outcome** - Index(es):

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