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