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

# Re: st: Test main effect (Beta) with significant interaction

 From Maarten Buis To statalist@hsphsun2.harvard.edu Subject Re: st: Test main effect (Beta) with significant interaction Date Fri, 24 Jun 2011 10:03:23 +0200

```On Thu, Jun 23, 2011 at 4:41 PM, Ricardo Ovaldia <ovaldia@yahoo.com> wrote:
> I have a linear regression model where my variable of interest interacts significantly with another variable. How do I test whether my variable of interest is significant (beta~=0)?

Conceptually, because you have added the interaction you now have
multiple effects for your variable of interest. If you interacted your
variable of interest with an indicator/dummy variable, you cant test
whether the effect in each of these groups is significant. That tends
to become unpractical when your interacting variable is continuous. In
that case I would choose a set of example values for the interacting
variable and test your parameter of interest for each of these example
values or graph the effect and its confidence interval against the
interacting variable. I added an example below for each of these
strategies.

*-------------------------- begin example ---------------------------------
sysuse auto, clear

// interacting with a indicator variable (foreign)
// --------------------------------------------------
// test in each group whether the effect of rep78 = 0
reg price i.foreign##c.rep78
test rep78 = 0
test rep78 + 1.foreign#c.rep78 = 0

// test wheter all effects of rep78 = 0
test (rep78 = 0) (rep78 + 1.foreign#c.rep78 = 0)

// alternatively, you can let Stata give you the
// separate effects of rep78 for foreign and domestic
// cars (the test for foreign and domestic cars can
// be read directly from the results):
reg price i.foreign i.foreign#c.rep78

// test whether all effects of rep78 = 0
test 0b.foreign#c.rep78 = 1.foreign#c.rep78 = 0

// interacting with a continuous variable (mpg)
// --------------------------------------------------

reg price c.mpg##c.rep78

// find example values, in this case I chose the
// 25th, 50th and 75th percentile of mpg
sum mpg, detail
local p25 = r(p25)
local p50 = r(p50)
local p75 = r(p75)

test rep78 + `p25'*c.mpg#c.rep78 = 0
test rep78 + `p50'*c.mpg#c.rep78 = 0
test rep78 + `p75'*c.mpg#c.rep78 = 0

// graph the effect of rep78 for different values of mpg
predictnl eff = _b[rep78] + mpg*_b[c.mpg#c.rep78], ci(lb ub)
twoway rarea lb ub mpg, sort || ///
line eff mpg, sort       ///
yline(0) legend(off)
*----------------------------- end example --------------------------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------
*
*   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/
```