I am using the community-contributed command gvselect that permits to perform best subsets variable selection (a statistical method to select variables).
After I used it, I obtain the following result:
. return list
macros:
r(best3) : " q105capitalisationboursireouvalo q12nombredefemmesauconseil q405existenceduncomitdesrmunrati"
r(best2) : " q12nombredefemmesauconseil q405existenceduncomitdesrmunrati"
r(best1) : " q405existenceduncomitdesrmunrati"
Then I need to use one of these macros in another statistical estimation method.
For example, I can use the first one as follows:
xtreg logremglobale `r(best3)' i.date, fe
(note the macro `r(best3)'
is used as an argument)
My framework entails that I do not know in advance which macro I need to use, so I determine it programmatically.
In this simplified example I may have to use r(best1)
, r(best2)
or r(best3)
(in reality there are more macros available) depending on the data.
All macros generated by gvselect have the same syntax: r(best
+ number
+ )
Once I have determined programmatically which macro I have to use (so for instance: number = 1) I'm stuck.
I don't know how to create the name of this macro programmatically and then use it as a normal macro. I'm not even sure if it is possible.
Could you help me with this ?
I have succeeded to replicate the macro name in a normal string as follows:
. scalar inum = 7
. gen macroname = "r(best" + string(inum,"%8.0g")+")"
. di macroname
r(best7)
But how can I use it in my estimation?
Obviously the following code doesn't work:
xtreg logremglobale `macroname' i.date, fe
The following works for me: