Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: compare coefficients from two regressions

From   Maarten buis <>
Subject   Re: st: compare coefficients from two regressions
Date   Wed, 2 May 2007 11:18:53 +0100 (BST)

--- Dirk Nachbar <> wrote:
> I run OLS regression on two subsamples and I want to test whether the
> coefficients in each regression are the same. I have problems with
> the store and test lines (see code below). How can I do it?
> reg y x if sample==1
> estimates store model1
> reg y x if sample==2
> test model1(x)==_x

It is much easier to do this in one model with an interaction term. You
would type the following:

recode sample = (1=0) (2=1)
/*I like to code this kind of variable 0 1 */
/*especially when dealing with interactions*/

gen  sampleXx = sample*x

reg y sample x sampleXx

The variable sample now has the value 0 (my coding) when dealing with
sample 1 (your coding). So the regression equation for sample 1 (your
coding) is:

y = b0 + b1*0 + b2*x + b3*0*x = b0 + b2*x

The regression equation for sample 2 (your coding) is:
y = b0 + b1*1 + b2*x + b3*1*x = (b0 + b1) + (b2 + b3)*x

So if the effect of x is the same in both samples b3 has to be zero. In
other words: testing whether x has the same effect in sample one and
two is the same as testing whether the coefficient sampleXx is zero.
This test is already in the output of -regress-. If you want to test
whether the entire regression equation is the same you would test that
both b1 and b3 are both simultaneously zero. This can with the -test-

This illustrates how much easier the interpretation of interaction
terms become if you make sure that the value zero for your variables
have a substantive interpretation, for instance by coding indicator
variables 0 1, instead of 1 2. 

Hope this helps,

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

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index