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

# st: calculate coefficients after regression with interactions

 From Eric Werfel To statalist@hsphsun2.harvard.edu Subject st: calculate coefficients after regression with interactions Date Tue, 3 Dec 2013 13:36:31 -0700

```Hi statalisters,

i am performing a regression which involves factorial interaction
between continuous and factor variables.  in simplified form, it looks
something like this:

reg log_y (c.log_k c.log_l)##(region year)

where region and year are both factor variables with multiple (more
than 2) values.
after performing the regression, i want to calculate and store the
constant and coefficients on log_k and log_l, for each observation,
taking into account interactions, in a new field.  in other words, i
want to store the coefficients, which will be different for each
combination of region and year, in a field for further calculations.
i know i could do something like this:

gen A= 0
replace A = _b[_cons] + _b[1.region] + _b[1850.year] if region == 1 &
year == 1850
replace A = _b[_cons] + _b[1.region] + _b[1860.year] if region == 1 &
year == 1860
...
gen alph = 0
replace alph = _b[log_k] + _b[1.region#c.log_k] +
_b[1850.year#c.log_k] if region == 1 & year == 1850
replace alph = _b[log_k] + _b[1.region#c.log_k] +
_b[1860.year#c.log_k] if region == 1 & year == 1860
...
etc....

but the number of permutations is very large, and to do this
completely would be impractical. i assume there MUST be some command
that will do this in one line.

any help is much appreciated.  thanks in advance.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```