# Re: st: How to calculate a new variable (interaction term) in ml model

 From Austin Nichols To statalist@hsphsun2.harvard.edu Subject Re: st: How to calculate a new variable (interaction term) in ml model Date Tue, 10 Mar 2009 12:00:07 -0400

```Marko Bender <Marko.Bender@wi.tum.de>:
I have never used -cmp- (on SSC), but it looks to me like you have two
endogenous vars on the RHS in Eq2: Y1 and Y1*X4.  You might try

g y1x4=Y1*X4
cmp (Eq3: y1x4 = X1 X2 X3)  (Eq2: Y2 = Y1 X4 y1x4)  (Eq1: Y1 = X1 X2 X3)

if that makes sense.

On Tue, Mar 10, 2009 at 11:05 AM, Marko Bender <Marko.Bender@wi.tum.de> wrote:
> Dear stata users,
>
> I’m trying to estimate a recursive multi-equation model with cmp.
> In the first equation  I would like to estimate a variable Y1 (dependent
> variable). Then I would like to include this variable as an independent
> variable in equation two. So far this is not a problem.
> The problem is that I also want to include Y1 as an interaction term with
> another variable X4. In order to do that I think I would need to generate a
> new variable, which includes the interaction term (X4*Y1). Unfortunately
> stata does not allow for any calculations within equations.
>
> Does anybody know how to do that? Does anybody know a work-around?
>
> The model looks like this:
>
> cmp (Eq2: Y2 = Y1 X4 X4*Y1)  (Eq1: Y1 = X1 X2 X3), ind(\$cmp_cont \$cmp_cont)
> quiet;
>
>
> The equations are defined according to the ml model eq syntax. So one
> thought of mine was to include a third equation, which generates my
> interaction term. Unfortunately I did not find a way to do that so far.
>
> I would be really greatefull for any suggestions and help!!!
>
> Thanks a lot,
> Marko

*
*   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/
```