Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Followup to: simple slopes between continuous variable and dichotomous moderator


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Followup to: simple slopes between continuous variable and dichotomous moderator
Date   Thu, 20 Jun 2013 10:11:12 +0200

That example should have included the main effect of foreign. There
are various ways in which you can obtain the simple slopes after such
an interaction effect:

*------------ begin example --------------
sysuse auto, clear
reg price c.mpg##i.foreign
margins foreign, dydx(mpg)

// or

reg price c.mpg#i.foreign i.foreign
// margins is now superfluous as you can directly
// read these numbers from the output of -regress-
margins foreign, dydx(mpg)

// or

reg price c.mpg#ibn.foreign i.foreign, hascons
// margins is now superfluous as you can directly
// read these numbers from the output of -regress-
margins foreign, dydx(mpg)

// or

bys foreign: reg price mpg
*------------- end example ---------------

I minor detail is that in the last model the standard errors are
different from the standard errors in the previous models. This
difference comes from the fact that in the first two models the error
variance is assumed to be the same for foreign and domestic cars,
while in the last model separate error variances are estimated for
both types of cars. If this worries you, just specify the
-vce(robust)- option for the model with interaction terms.

Hope this helps,
Maarten


On Thu, Jun 20, 2013 at 4:53 AM, David de Jong <davidcdejong@gmail.com> wrote:
> Dear STATA folks,
>
> I’m trying to figure out how to plot simple slopes to unpack an
> interaction between a continuous and categorical variable in a
> regression analysis. Let’s say I want to look at the simple slopes for
> price on mpg, for both foreign and domestic cars.
>
> In my searches, I came across this exchange from a few years ago:
>
> --- On Tue, 1/2/11, Rodrigo Isidor wrote:
>
>> Has anyone written a program to calculate simple slopes for
>> interactions between a continuous variable and dichotomous
>> moderator in linear regression analysis? To my knowledge,
>> sslope from Jeffrey Simons is just for continuous
>> variables.
>
> There is no need to write a program for that. You can use Stata's
> factor variable notation for it. In the example  below the first slope
> for mpg is for domestic cars and the second is for foreign cars.
>
> *------------ begin example --------------
> sysuse auto, clear
> reg price c.mpg#i.foreign
> *------------- end example ---------------
>
> Hope this helps, Maarten
>
> [end previous exchange]
>
> I tried that approach, as well as using -margins-, with the following:
>
> margins i.foreign, dydx(mpg)
>
> These two approaches produced very different results. The –margins-
> approach gives me results more consistent with results from simply
> splitting the file by foreign and looking at the correlation between
> price and mpg. I’m sure that I’m missing something. Can anyone advise
> as to why these procedures are giving me such different results, and
> if I’m doing either incorrectly?
>
> Thank you,
>
> David de Jong
>
> ~
> Department of Clinical and Social Sciences in Psychology
> University of Rochester
> 498c Meliora Hall
> Rochester, NY 14627
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/



-- 
---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index