Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

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


From   "Clyde Schechter" <clyde.schechter@einstein.yu.edu>
To   statalist@hsphsun2.harvard.edu
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: clyde.schechter@einstein.yu.edu

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index