# Plotting an interaction between a continuous IV and DV and an ordinal covariate, can I use a bar chart?

I think my question is similar to this one: How do you plot an interaction between a factor and a continous covariate?

My IV and DV are both scales, and my interaction term has 3 levels. I am trying to look for associations between my IV and DV so I need to be using correlation coefficients rather than means... I think!

Basically, someone suggested to me doing a bar chart (because it would show the difference more clearly), with the three interaction levels on the x axis and the IV/DV r on the Y axis. I think that's what they were suggesting but it has completely baffled me! I have no idea how to use r in this way...

Any help would be great :)

EDIT: Just to clarify, I have done a regression to look for significance, and then also an ANCOVA because it was significant. But what i'm really asking is for a way to illustrate my findings in a figure.

• If you have three levels of you interaction term, it does not sound like a nominal(i.e. yes/no) but an ordinal or categorical term). I suggest editing you question ad/or title to clarify. May 13, 2014 at 12:37
• @Alexis "nominal" means two-level? I can't find any support for that definition. Is there a particular context for it?
– xan
May 18, 2014 at 20:10
• @xan I guess I interpret nominal as always implying dichotomous/binary representation, since multiple (not ordinal) categories are analytically represented with binary indicators. May 19, 2014 at 17:42

No, you will probably not look at correlations - the appropriate method is ANCOVA with an interaction term.

You will want to plot the DV against the IV separately per level of the factor. I don't really see how barplots can help here. Let's create some toy data in R:

set.seed(1)
ff <- factor(rep(LETTERS[1:3],10))
iv <- rnorm(length(ff))
dv <- rnorm(length(ff),as.numeric(ff)-as.numeric(ff)*iv)
foo <- data.frame(ff,iv,dv)


Now, there are at least two different ways of plotting this. You can create an interaction plot of the raw data like this:

plot(range(iv),range(dv),type="n",xlab="IV",ylab="DV")
for ( ii in seq_along(unique(ff)) ) {
with(foo[foo$ff==unique(ff)[ii],], lines(sort(iv),dv[order(iv)],lty=ii,type="o",pch=19)) } legend("topright",inset=.01,lty=seq_along(unique(ff)),legend=unique(ff))  Or you can fit a model and plot the fitted values: model <- lm(dv~iv*ff,foo) plot(range(iv),range(dv),type="n",xlab="IV",ylab="DV") for ( ii in seq_along(unique(ff)) ) { newdata <- data.frame(ff=unique(ff)[ii],iv=range(iv[ff==unique(ff)[ii]])) lines(newdata$iv,predict(model,newdata),lty=ii)
}
legend("topright",inset=.01,lty=seq_along(unique(ff)),legend=unique(ff))


This second alternative of course depends crucially on the model you assume. You can (really: should) refine it with confidence regions.

(You can also do something similar with the R interaction.plot() function, but I honestly don't like its output.)

• ANCOVA is necessarily the appropriate method: regressions (whether OLS, nonlinear, nonparametric) are also appropriate. Nice answer though. May 13, 2014 at 12:46
• Thanks. I assume you wanted to write that "ANCOVA is not necessarily the appropriate method"? (Which I agree with, but ANCOVA is usually a good first step - better than correlations, anyway.) May 13, 2014 at 12:48
• I'm pretty sure Alexis meant ANCOVA isn't necessarily the method. I'd carry this further. As soon as you put an interaction in then it isn't ANCOVA anymore. ANCOVA is about ignoring the covariate because you know it has no relationship to the other predictors. If you're assessing the covariate as a predictor it's not ANCOVA but regression analysis.
– John
May 13, 2014 at 12:49
• Oops. yep: "ANCOVA is not." May 13, 2014 at 12:53

Typically two continuous variables, one dependent, one independent are plotted with some kind of regression line (dependent variable on the y axis). With a nominal (or categorical) interaction term, you would simply plot two (or more) regression lines on the same graph, and label each line according to the values of the interaction term.