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]
st: create a variable with estimated coefficients on dummies
From
"Bernini, Michele" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: create a variable with estimated coefficients on dummies
Date
Wed, 15 Aug 2012 20:27:42 +0200
Dear Statalister,
I am programming a loop to execute the following operations:
1- estimate a regression on a big set of dummies (country-hs6 product categories)
2-create a variable with the estimated coefficients on the dummies. For each observation (row) the value of this variable should correspond to the coeff. on the dummy that assumes value 1 for that observation.
I tried something like that:
gen ch=.
levelsof hs4, local(lvl_hs4) \\ level at which I run separate regressions
foreach element in `lvl_hs4'{
xi: reg Y X i.CH i.t if hs4==`element'
levelsof CH, local(clist)
foreach c of local clist {
replace ch = _b[_ICH_`c'] if CH == `c' \\ here I try to give the variable ch the value of the coefficients
}
}
my problem is that the local `clist' includes also the missing category of the dummies, so when it looks for _b[_ICH_`c'] where c = "missing category" the loop aborts. In either words I would either need the local `clist' to include only the dummies created from CH in each regression, or to find another way to do that. I also tried with svmat but then I cannot match coefficients on the new variable 'ch' with the observations with each category in the dummies.
Thanks in advance for your help,
Michele Bernini
Phd Candidate
School of International Studies (SIS)
University of Trento
Via Verdi, 8/10
I-38122 Trento
Italy
Tel. +39 3491831687
*
* 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/