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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: create a variable with estimated coefficients on dummies


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: create a variable with estimated coefficients on dummies
Date   Wed, 15 Aug 2012 21:08:07 +0200

On Wed, Aug 15, 2012 at 8:27 PM, Bernini, Michele wrote:
> 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.


Sounds to me like you don't need a loop, it is just a matter of
predicting and than subtracting the constant:

*-------- begin example ----------
sysuse nlsw88, clear
reg wage i.occupation

predict coef
replace coef = coef - _b[_cons]

list occupation coef in 1/5, nol
*--------- end example -----------

Hope this helps,
maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   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