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

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

From   "Nick Cox" <>
To   <>
Subject   RE: st: RE: categorising continuous variable and generating mean outcome
Date   Wed, 18 Feb 2009 11:45:59 -0000

It seems that you are not tied to anything much beyond the idea of seeing a graphical summary of Y w.r.t. X. 

If that's so, any number of wired-in commands can get you there in one, e.g. -twoway mband-, -lowess-, -lpoly-, etc. 

But they are not always sensitive to binary variables, if that's what you have, so that in some cases the summary can be reported as outside [0,1]. If you have a continuous proportion, the same proviso applies, but less so. 


Galina Hayes

Thanks Howie, definitely helpful.

"Howard Lempel" <>

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-.

Galina Hayes

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,

*   For searches and help try:

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