
You can also import the data directly into R via the URL using the following code:ĭat$prog <- factor(dat$prog,labels=c("jog","swim","read"))ĭat$gender <- factor(dat$gender,labels=c("male","female")) The dataset used in the seminar can be found here: exercise.csv. install.packages("emmeans", dependencies=TRUE) install.packages("ggplot2", dependencies=TRUE) Please also make sure to have the following R packages installed, and if not, run these commands in R (RStudio). Requirementsīefore beginning the seminar, please make sure you have R and RStudio installed. This page covers two way and three way interaction decompositions in the SAS programming language. This seminar page was inspired by Analyzing and Visualizing Interactions in SAS.
(Optional) Plotting simple effects using bar graphs with ggplot. Plotting the categorical by categorical interaction. Simple effects in a categorical by categorical interaction. Plotting the continuous by categorical interaction. (Optional) Flipping the moderator (MV) and the independent variable (IV). Obtaining simple slopes by each level of the categorical moderator. Interpreting the coefficients of the continuous by categorical interaction. (Optional) Creating a publication quality graph with ggplot. (Optional) Manually calculating the simple slopes. Testing differences in predicted values at a particular level of the moderator. Testing simple slopes in a continuous by continuous model. Plotting a continuous by continuous interaction. Simple slopes for a continuous by continuous model. Proceed through the seminar in order or click on the hyperlinks below to go to a particular section: Is there a difference in the relationship of X on Y for different values of W? (comparing simple slopes). What is relationship of X on Y at particular values of W? (simple slopes/effects). What is the predicted Y given a particular X and W? (predicted value). We can probe or decompose each of these interactions by asking the following research questions: Throughout the seminar, we will be covering the following types of interactions:
For users of Stata, refer to Decomposing, Probing, and Plotting Interactions in Stata.
Confidence interval graph r how to#
This seminar will show you how to decompose, probe, and plot two-way interactions in linear regression using the emmeans package in the R statistical programming language.