# Re: st: Matrix manipulation.

 From Maarten buis To statalist@hsphsun2.harvard.edu Subject Re: st: Matrix manipulation. Date Fri, 2 May 2008 06:50:06 +0100 (BST)

```--- Victor Mauricio Herrera <vherrera@wisc.edu> wrote:
> > > I'm running a regression model and then using the matrix of
> > > coefficients e(b) for additional calculations. In the model I
> > > have an interaction term between two dichotomous variables (i.e.
> > > gender-by-obesity, with women coded as 0 and men coded as 1).
> > > The coefficient for obesity in women is already in e(b) but not
> > > the coefficient for obesity in men. I know I can easily
> > > calculate this coefficient using lincom, but the problem is that
> > > I need to add the coefficient for obesity in men as an additional
> > > column to the e(b) matrix, to be able to do additional
> > > calculations using e(b). In not very familiar with matrix
> > > manipulation and I wonder if there is an easy way to do this.

--- Maarten buis wrote:
> >  The best way is to change the variables you add to your model
> > instead of the coefficient matrix. In the example below you get
> > the coefficient of south (in your case obesity) for college
> > southXcollgrad, and the coefficient of south of non-college
> > graduates (in your case men) in the coefficient of southXnoncoll.
> > Notice that in this case we leave out the main effect of south
> > (in your case obesity).

> >  *------------ begin example ------------
> >  sysuse nlsw88, clear
> >  gen noncoll = !collgrad
> >  gen southXnoncoll = south*noncoll
> >  gen ln_w = ln(wage)
> >  *------------ end example ---------------
> >  (For more on how to use examples I sent to the Statalist, see
> >  http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

--- Victor Mauricio Herrera <vherrera@wisc.edu> wrote:
> Marteen's suggestion is well appreciated. However, variables defined
> in this way tend to be collinear and are dropped from the regression
> model, leading to non-existing coefficients and non-conformable
> matrices.

If you execute the example I have given, as is discussed in
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html#work , than you will
see that that is not the case.

The most likely mistake would be that you have kept in the main effect.
As I warned you, you should leave that out in this case. Under normal
circumstances (two dummies and an interaction), the coefficient of
obesity would measure the effect of obesity for women, and the
interaction would measure how much the effect of men differs from the
effect of women. In case of the example I have given (two interaction
effect obesity X men and obesity X women) you have the effect of
obesity for men and the effect of obesity for women. Now there can no
longer be a main effect: what would that be supposed to measure?

-- Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

__________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
*
*   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/
```