[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Maarten Buis" <M.Buis@fsw.vu.nl> |

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

Subject |
st: RE: Generating grouped variable list of xi'd variables via column names |

Date |
Fri, 13 Jul 2007 13:47:45 +0200 |

--- K Jensen wrote: > I would like to generate lists of groups of variables that have been > generated via xi from the column names of the vector e(b) after > regression commands. > It's probably easier to explain with an example... > > sysuse cancer > stset studytime, fail(died) > gen randcat=1 > replace randcat=2 if uniform()>1/3 > replace randcat=3 if uniform()>2/3 > xi:stcox i.drug age i.randcat > > . matrix list e(b) > > e(b)[1,5] > _Idrug_2 _Idrug_3 age _Irandcat_2 _Irandcat_3 > y1 -1.7300519 -3.2313217 .12791436 -.93457115 -.77850524 > > I would like to take the column names from e(b) to generate a varlist > of the xi-generated variable groups, something like: >_Idrug* _Irand* With the -unab- command you can get a list of all variable names starting with _I, with the -indeplist- command (downloadable from ssc) you can get a list of all independent variables in your model, and with the list extended macro function you combine these two list to create a list of all _I variables that are in your model. See the example below: *-------------- begin example ----------- sysuse cancer, clear stset studytime, fail(died) gen randcat= ceil(3*uniform()) xi:stcox i.drug age i.randcat indeplist, local di "`X'" unab all_I : _I* local model_I : list all_I & X di "`model_I'" *-------------- end example ------------- (For more on how to use examples I sent to the Statalist, see http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html ) Hope this helps, Maarten Ps. Notice that I created the variable randcat differently. You created it by calling the function uniform() twice. That way -uniform()>1/3- and -uniform()>2/3- can both be true since they refer to different random numbers. More on this in Stata Tip 48 which will appear in the next Stata Journal. A pre-publication draft is downloadable from my website. ----------------------------------------- Maarten L. Buis Department of Social Research Methodology Vrije Universiteit Amsterdam Boelelaan 1081 1081 HV Amsterdam The Netherlands visiting address: Buitenveldertselaan 3 (Metropolitan), room Z434 +31 20 5986715 http://home.fsw.vu.nl/m.buis/ ----------------------------------------- * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: RE: Generating grouped variable list of xi'd variables via column names***From:*"K Jensen" <k.x.jensen@googlemail.com>

- Prev by Date:
**st: Generating grouped variable list of xi'd variables via column names** - Next by Date:
**Re: st: RE: Generating grouped variable list of xi'd variables via column names** - Previous by thread:
**st: Generating grouped variable list of xi'd variables via column names** - Next by thread:
**Re: st: RE: Generating grouped variable list of xi'd variables via column names** - Index(es):

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