9/28/2020 · Example: Interaction Plot in R Suppose researchers want to determine if exercise intensity and gender impact weight loss. To test this, they recruit 30 men and 30 women to participate in an experiment in which they randomly assign 10 of each to follow a program of either no exercise, light exercise, or intense exercise for one month.
interaction.plot(x.factor, trace.factor, response, fun = mean, type = c(l, p, b, o, c), legend = TRUE, trace.label = deparse(substitute(trace.factor)), fixed = FALSE, xlab = deparse(substitute(x.factor)), ylab = ylabel, ylim = range(cells, na.rm = TRUE), lty = nc:1, col = 1, pch = c(1:9, 0, letters), xpd = NULL, leg.bg = par(bg), leg.bty = n, xtick = FALSE, xaxt = par(xaxt), axes = TRUE, ), Plot interaction effects in regression models. interact_plot plots regression lines at user-specified levels of a moderator variable to explore interactions. The plotting is done with ggplot2 rather than base graphics, which some similar functions use.
My first attempts at the plots involved setting them up element by element. Just going over some examples I decided to turn the basic plot (for a 2 x 2 ANOVA) into a simple function. Nothing fancy, just a regular interaction plot in black and white that I think is prettier than the SPSS, Excel or R defaults.
interaction.plot (x.factor, trace.factor, response, fun = mean, type = c (l, p, b, o, c), legend = TRUE, trace.label = deparse1 (substitute (trace.factor)), fixed = FALSE, xlab = deparse1 (substitute (x.factor)), ylab = ylabel, ylim = range (cells, na.rm = TRUE), lty = nc: 1, col = 1, pch = c (1: 9, 0, letters), xpd = NULL, leg.bg = par (bg), leg.bty = n, xtick = FALSE, xaxt = par (xaxt), axes = TRUE,…
R Handbook: Factorial ANOVA: Main Effects, Interaction …
Plotting Interaction Effects of Regression Models, Plotting Interaction Effects of Regression Models, interaction.plot(x.factor, trace.factor, response, fun = mean, type = c(l, p, b, o, c), legend = TRUE, trace.label = deparse1(substitute(trace.factor)), fixed = FALSE, xlab = deparse1(substitute(x.factor)), ylab = ylabel, ylim = range(cells, na.rm = TRUE), lty = nc:1, col = 1, pch = c(1:9, 0, letters), xpd = NULL, leg.bg = par(bg), leg.bty = n, xtick = FALSE, xaxt = par(xaxt), axes = TRUE, …)