Jamie--
I seem to have left out of my example a couple of crucial -levelsof-
commands, without which the locals o and r are empty and no variables
are created in an empty loop. Note, BTW, that my examples should not
need to be saved to a do-file, but can be cut and pasted in their
entirety into the Command window in Stata 9. The point, however, was
valid--that you retain more command over which categories are excluded
if you make your own dummies (see also -devcon- via -ssc install
devcon- and working papers by Yun at iza.org on how to include all the
categories by averaging across all possible specifications that
exclude one, but only estimating one model).
webuse nlswork, clear
qui xi: logistic coll i.occ*i.race
testparm _IoccX*
levelsof occ, local(o)
levelsof race, local(r)
foreach i of local o {
qui g byte o_`i'=(occ==`i') if !mi(occ)
foreach j of local r {
qui g byte o_`i'r_`j'=(occ==`i' & race==`j') if !mi(race,occ)
}
}
foreach j of local r {
qui g byte r_`j'=(race==`j') if !mi(race)
}
qui logistic coll o_* r_*
testparm o_*r_*
drop o_1 r_1
qui logistic coll o_* r_*
testparm o_*r_*
On 5/7/07, Jamie Fagg <[email protected]> wrote:
Dear Austin,
Firstly, thanks for your help with my question and sorry for
the delay in acknowledging your help.
I tried to run your .do file but unfortunately there seems to be a
problem in terms of generating the interaction dummy variables (that is
what the foreach loops are doing aren't they?). I am running Stata
Intercooled version 9 on XP if that is relevant, see below for output:
variable o_* not found
*
* 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/