Statalist The Stata Listserver

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

Re: st: compare coefficients from two regressions

From   "Austin Nichols" <>
Subject   Re: st: compare coefficients from two regressions
Date   Wed, 2 May 2007 08:28:22 -0400

I think it is dangerous to start by using -recode- (what if sample==0
means something else already? what if there are multiple other values
of sample in the data?) but you could achieve the desired effect with:

g s2=sample-1 if inlist(sample,1,2)
gen  s2x = s2*x
reg y s2 x s2x
test s2x

While I, like Maarten, prefer the interacted version, one can also get
the test Dirk actually requested using -suest- (see the help file):

sysuse auto, clear
reg pr mpg if for==1
est sto f1
reg pr mpg if for==0
est sto f0
suest f0 f1
test [f0_mean]mpg=[f1_mean]mpg
g formpg=fore*mpg
reg pr mpg fore form
test form

Note that these approaches differ slightly, as the -suest- approach
does not constrain the variance of the residual to be the same across

On 5/2/07, Maarten buis <> wrote:
--- 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)
*   For searches and help try:

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