Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

RE: st: --estimates table, drop()" and FACTOR variables (texdoc)


From   "Clyde Schechter" <[email protected]>
To   [email protected]
Subject   RE: st: --estimates table, drop()" and FACTOR variables (texdoc)
Date   Tue, 2 Aug 2011 21:38:18 -0700

"I run a few specifications then try to drop a factor variable (~300
dummies) but
--estimates table-- throws an error.&nbsp; Am I doing something
wrong?&nbsp; If
there is an issue with factor variables, is there a known workaround?"

This problem arises with several commands that require you to specify the
individual factor levels you want.  One solution is to build a macro that
contains what you need and then use that.  Start with -levelsof- and then
replace all the spaces by .varname.  Since the macro produced by
-levelsof- doesn't end with a space, you also need to stick .varname on
the very end.  Something like:

levelsof hsacode if e(sample), local(hsacodes)
local hsacodes: subinstr local hsacodes " " ".hsacode ", all
local hsacodes `hsacodes'.hsacode
... // WHATEVER
estimates table, drop(`hsacodes')

Note that the if e(sample) clause is necessary so that the macro
`hsacodes' will only have terms that actually appear in the model.  You
might also have to fiddle with this a little more to eliminate the base
category for i.hsacodes--I don't know if -estimates table, drop()- will
choke on that or not.  [I use this technique mainly with the -test-
command, and -test- is quite tolerant of the base level.  -estimates
table- may or may not be.]

The second and third lines can also be replaced by a single call to the
-postlist- command in Nick Cox's -listutil- package if you have that
installed.

Hope this helps.


Clyde Schechter
Department of Family & Social Medicine
Albert Einstein College of Medicine
Bronx, NY, USA

Please note new e-mail address: [email protected]

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index