.
(Hmm... not sure why the first line of my message was cut off....)
On Jul 5, 2004, at 2:39 PM, Michael S. Hanson wrote:
tests sums of coefficients from a regression in a flexible, general
manner. As an example, I have a large number of regressions of the
form
. reg y x* z*
where x* is a long (and varying across regression specification) list
of regressors. I want to test the null hypothesis that the sum of the
x variables in each regression is zero. Ideally, I am looking for an
extension to -testparm-, such as
. testparm x*, sum
which -- similar to the way the -equal- option modifies the null for
-testparm- to test for joint equality -- would return the test
statistic for the null that the sum of the variables in varlist x* are
zero. (I have looked at the code of "testparm.ado" to see if I could
make the addition myself, but the changes are well beyond my meager
Stata programming skills. (I have spent days just trying to figure
out how to recursively define local macros in loops....)
Answering my own question (after tearing out some more hair first),
the following -- ultimately quite simple -- code seems to do the trick.
Improvements or alternatives are welcome.
. local testsum "0"
. foreach var of varlist x* {
. local testsum = "`testsum'+`var'"
. }
. test `testsum' = 0
Hope someone else finds this helpful.
-- Mike
*
* 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/