Interaction between two continuous variables

From PsychWiki - A Collaborative Psychology Wiki

(Difference between revisions)
Jump to: navigation, search
Jchristie (Talk | contribs)
(R commands)
 
(41 intermediate revisions not shown)
Line 1: Line 1:
-
Statistical programs, like SPSS, do not always have "point-and-click" commands for every possible statistical test. This page is a description of how to test the interaction between two continuous variables. Below, an [[#What is an interaction? | explanation of interactions]] is presented,  then the '''[[#Three Steps | three steps to conduct the interaction]]''' is described, and examples are given to help in understanding the steps involved.
+
Statistical programs, like SPSS, do not always have "point-and-click" commands for every possible statistical test. This page is a description of how to test the interaction between two continuous variables. Three approaches are described below:<br>
 +
(1) '''[[#Three Steps Using SPSS | three steps to conduct the interaction using commands within SPSS]]''', and<br>
 +
(2) '''[[#Interaction! software | Interaction! software]]''' by Daniel S. Soper that performs statistical analysis and graphics for interactions between dichotomous, categorical, and continuous variables.<br>
 +
(3)  '''[[#R commands | R commands]]''' for executing the analysis.
-
==What is an interaction?==
+
<nowiki>*</nowiki>For a description of what is an interaction and main effects, please see the accompanying page about [[What is an Interaction?]].
-
*Interactions are when the effect of two, or more, variables is not simply additive. This page describes the interaction between two variables. It is possible to examine the interactions of three or more variables but this is beyond the scope of this page.
+
-
*Example of interaction - One possible interaction is the effect of energy bars and energy drinks on time to run the 1500 meters. The quantity of energy bars and energy drinks represent two variables. The dependent variable is the time taken to run 1500 meters.
+
-
*# ''Example 1'' - An interaction occurs if running speed improves by more than just the additive effect of having either an energy bar or an energy drink. For example, imagine eating a certain amount of energy bars increases running speed by 5 seconds, and drinking energy drinks increases running speed by 3 seconds. An interaction occurs if the joint effect of energy bars and energy drinks increases running speed by more than 8 seconds, such as liquid in the drink amplifying the ability to digest the energy in the bar leading to faster times.
+
-
*# ''Example 2'' - Another example of an interaction effect would be if running time worsened by the joint effect of energy bars and energy drinks -- perhaps the person feels bloated from eating ''and'' drinking and so are unable to run quickly.
+
-
*# ''Example 3'' - A third and final example of an interaction is that alone neither variable may have an effect on running speed, such as imagining that an energy bar by itself, or an energy drink by itself, is unable to increase running speed. But, there might be an interaction effect that influences running speed when you eat the bar ''and'' drink the drink, such as the energy bar having a chemical that unleashes the power of the energy drink to increase running speed.
+
-
*For those more technically minded, here is the algebra. An interaction effect reflects the effect of the interaction controlling for the two predictors themselves.
+
-
*#In the following examples:
+
-
*#:energy bar = X1,
+
-
*#:energy drink = X2
+
-
*#:the interaction = X1*X2,
+
-
*#:Y = running speed
+
-
*#Here is the formula for: Running speed = intercept + b1energu drink + b2energy bar + b3(bar * drink) + ei
+
-
*#:Y<sub>''i''</sub> = ''b''<sub>0</sub> + ''b''<sub>1</sub>X1<sub>''i''</sub> + ''b''<sub>2</sub>X2<sub>''i''</sub> + ''b''<sub>3</sub>(X1<sub>''i''</sub> X2<sub>''i''</sub>) + ''e<sub>i</sub>''
+
-
*#This formula can be rewritten as
+
-
*#:Y<sub>''i''</sub> = (''b''<sub>0</sub> + ''b''<sub>2</sub>X<sub>2''i''</sub>) + (''b''<sub>1</sub>+ ''b''<sub>3</sub>X<sub>2''i''</sub>) X<sub>1''i''</sub> + ''e<sub>i</sub>''
+
-
*#:where (''b''<sub>1</sub>+ ''b''<sub>3</sub>X<sub>2''i''</sub>) represents the effect of X<sub>1</sub> on Y at specific levels of X<sub>2</sub>
+
-
*#:and ''b<sub>3</sub>'' indicates how much the slope of X<sub>1</sub> changes as X<sub>2</sub> goes up or down one unit.
+
-
*#It is then possible to factor out X<sub>2</sub>
+
-
*#:Y<sub>''i''</sub> = (''b''<sub>0</sub> + ''b''<sub>1</sub>X<sub>1''i''</sub>) + (''b''<sub>2</sub>+ ''b''<sub>3</sub>X<sub>1''i''</sub>) X<sub>2''i''</sub> + ''e<sub>i</sub>''
+
-
*#:where (''b''<sub>2</sub>+ ''b''<sub>3</sub>X<sub>1''i''</sub>) represents the effect of X<sub>2</sub> on Y at specific levels of X<sub>1</sub>
+
-
*#:and ''b<sub>3</sub>'' indicates how much the slope of X<sub>2</sub> changes as X<sub>2</sub> goes up or down one unit.
+
 +
__TOC__
-
==Three Steps==
+
==Three Steps using SPSS==
There are three steps involved to calculate the interaction between two continuous variables.
There are three steps involved to calculate the interaction between two continuous variables.
===► '''Center''' the two continuous variables===
===► '''Center''' the two continuous variables===
Line 62: Line 45:
===► '''Create the interaction term'''===
===► '''Create the interaction term'''===
*How to create the interaction term?
*How to create the interaction term?
-
*#Simply multiple together the two new centered variables.
+
*#Simply multiply together the two new centered variables.
*#In our example, multiple IQ_c x study_c
*#In our example, multiple IQ_c x study_c
-
*#In SPSS this is accomplished using the "compute" command and typing IQ_c * study_c in the open box.
+
*#In SPSS this is accomplished using the "compute" command and typing "IQ_c * study_c" in the open box.
Line 71: Line 54:
*How to conduct the regression analysis?
*How to conduct the regression analysis?
*#In SPSS, click on "linear regression" and enter the test score variable as the DV.
*#In SPSS, click on "linear regression" and enter the test score variable as the DV.
-
*#Enter the new centered variables as the IVs in the regression analysis
+
*#Enter the newly centered variables as the IVs in the regression analysis.
*#Click "next" and enter both centered variables AND the new interaction variable as the IVs.
*#Click "next" and enter both centered variables AND the new interaction variable as the IVs.
-
*#Run the analysis
+
*#Run the analysis.
 +
*#In the output, look at the second model in the "Coefficients" box. An interaction is depicted as a significant value for the interaction variable. A significant value for the centered variables can be conceptualized as a "main effect".
 +
*#If your interaction term is then significant it is recommended you produce plots to assist the interpretation of your interaction.
 +
 +
==Interaction! software==
 +
*Given the tedious nature of using the [[#Three Steps using SPSS | three steps described above]] every time you need to test interactions between continuous variables, I was happy to find Windows-based software which analyzes statistical interactions between dichotomous, categorical, or continuous variables, AND plots the interaction graphs.
 +
*The software is called [http://www.danielsoper.com/Interaction/default.aspx Interaction!] from a graduate student in the Information Systems department at Arizona State University. I found it very easy to use. There is also a good [http://www.danielsoper.com/Interaction/help.aspx Help section] on the website.
 +
*There is an SPSS macro for conducting cross-product regressions [http://www.ilstu.edu/~wjschne/tests.html here].
 +
==R commands==
 +
*Assuming you have your data in a comma delimited text file called 'myGreatData.csv' and the first line (header) labels the three columns 'y, x1, x2', the following command will generate your regression.  Note that these commands are the minimum and assume the same things are true as are true in the SPSS example above (centering, assumptions of the regression are met, etc.).
 +
*#setwd( 'dataDir' ) #Set the working director to the path to your data file.  You could skip this step and just enter the full path into the next step.
 +
*#dat <- read.csv( 'myGreatData.csv', header = TRUE ) #load your data file into the variable 'dat'
 +
*#m <- lm( y ~ x1 * x2, data = 'dat') #do the regression
 +
*#summary(m) #view the results
-
 
+
----
-
 
+
◄ Back to [[Analyzing Data]] page
-
 
+
-
==Plotting the interaction==
+

Latest revision as of 16:49, 5 August 2011

Statistical programs, like SPSS, do not always have "point-and-click" commands for every possible statistical test. This page is a description of how to test the interaction between two continuous variables. Three approaches are described below:
(1) three steps to conduct the interaction using commands within SPSS, and
(2) Interaction! software by Daniel S. Soper that performs statistical analysis and graphics for interactions between dichotomous, categorical, and continuous variables.
(3) R commands for executing the analysis.

*For a description of what is an interaction and main effects, please see the accompanying page about What is an Interaction?.


Contents


Three Steps using SPSS

There are three steps involved to calculate the interaction between two continuous variables.

Center the two continuous variables


Create the interaction term


Conduct Regression



Interaction! software

R commands


◄ Back to Analyzing Data page

Personal tools
Namespaces
Variants
Actions
Navigation
Interaction
Toolbox