Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

I would like to plot on the same graph the interaction between my continuous predictor and my categorical moderator. I know how to do it when both are categorical (factor interaction), but don't really know how to do it when one is continuous and one is categorical.

share|improve this question

2 Answers 2

If you're talking about an interaction in a general linear model (e.g., ANCOVA), and if your categorical moderator has a reasonably small number of levels, you can plot separate regression lines for each level of the moderator. If you want these on the same plot, superimpose them, code by color or line type, and provide a legend. One of your plot's axes will represent the continuous predictor (presumably the horizontal "$x$" axis), and the other will represent the dependent variable, which I'm assuming is continuous. If your categorical predictor (moderator) has more than four levels, that might get a little too busy for one plot, but I'm not aware of a better method for such circumstances that doesn't resort to separate plots for each level.

share|improve this answer
    
thanks for your reply! I am indeed referring to a GLM (univariate),which only lets me plot estimated marginal means for factor interactions. I am not sure how to superimpose as you say...I work with SPSS. could you please detail a bit more on that? –  Andreea Jan 14 at 13:30
1  
For SPSS just save the predicted values after estimating the model. Then in the graph plot the predicted values on the Y axis, and the continuous predictor on the X axis, then use the categorical variable to group the lines or points. –  Andy W Jan 14 at 13:35
    
thanks! just to clarify, which graph plot exactly do I need to produce for this? Is it a scatter plot with regression line? If so, then I would need to produce 3 different graphs for the 3 different levels of my moderator...how do I put it on the same graph? Also just to clarify that the predicted values take into consideration the adjusted regression with covariates? –  Andreea Jan 14 at 13:50
1  
@Andreea, I have added an answer to address your comment. –  Penguin_Knight Jan 14 at 14:31

Just to address the following comment:

thanks! just to clarify, which graph plot exactly do I need to produce for this? Is it a scatter plot with regression line? If so, then I would need to produce 3 different graphs for the 3 different levels of my moderator...how do I put it on the same graph? Also just to clarify that the predicted values take into consideration the adjusted regression with covariates?

Here is how to do it in SPSS. I use the Employee.sav data as example. Suppose we'd like to use salary as outcome, beginning salary as the continuous predictor and job category as the categorical predictor:

enter image description here

Go to Graph > Legacy > Scatter:

enter image description here

Choose just simple scatter plot is fine. Then, fill in the variables:

enter image description here

You'll then see the scatter plot. Double click on the scatter plot to open the chart editor. At the top, click the icon to "fit lines to subgroups." See pic below:

enter image description here

Done:

enter image description here

Now, whether you use the original salary variable as outcome or the predicted salary as outcome adjusted for the other third or more predictors is a matter of your purpose. The original salary will fit better as exploration, while the predicted salary will be more suitable as presenting your regression results.

share|improve this answer
    
thank you! This confirms what I did is ok, I have other covariates involved so I have to use predicted outcome (saved as unstandardised in the regression model). This is of much help! –  Andreea Jan 14 at 15:45
    
I have another question: I am unsure that I should stick with continuous predictors in my regression analysis, as the associations, while significant both before and after adjustment, they seem to be driven by big outliers. If I split my predictor into 3 categories (zero frequencies, below and above median), then I do not have any significant associations with the continuous outcome anymore. Any suggestions of what the best way to go would be? thank you –  Andreea Jan 14 at 20:25
    
How many "big outliers" are we talking about? Do you have any other unusual information about them that could justify their exclusion from your sample? If it's less a matter of outliers than of a non-normal distribution, you might consider fitting a robust/nonparametric GLM to reduce bias in your results. –  Nick Stauner Jan 14 at 20:43
    
thanks for the suggestion. My continuous outcomes don't appear to be normally distributed when I do a hystogram, but when I do a residuals plot (save standardised residuals in GLM), and I look for an approximately rectangular scatter, they seem to fit into this pattern, which suggests similar levels of variation across the range of predicted value, so that's ok I'd say. In terms of outliers, there seem to be between 1-3 outliers judging from the scatter plot (i can't seem to be able to copy-paste the plots here). I have never worked with nonparametric GLM so not sure where to find that in SPSS –  Andreea Jan 14 at 22:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.