# Investigating Interaction Effects With Response Surface Analysis

Autor*innen: Martin Greisel & Kaley Lesperance

In usual multiple regression analysis, researchers are often interested in interactions between predictor variables. However, these interactions are often investigated using linear interaction terms only. The response surface analysis allows for a more in-depth understanding of the actual interactions while the resulting response surface plots are still easy to interpret. We illustrate this approach with data from PISA 2012-2013 (campus file) for three different dependent variables: achievement in math, science, and reading. Therefore, we used the R-package RSA (Schönbrodt, F. D. & Humberg, S. (2021). RSA: An R package for response surface analysis (version 0.10.4). Retrieved from https://cran.r-project.org/package=RSA) which produces RSA-plots based on the graphics engine from the lattice-package.

The interaction effects differ for each dependent variable. The plots above might be interpreted as follows:

### Math
Students with a positive attitude toward school benefit from cognitively activating lessons as they perform better in math. However, this effect inverses for students with a negative attitude toward school: They perform worse in math with increasingly cognitively activating lessons.

### Science
In science, students with an average to positive attitude toward school perform best, as long as their lessons are at least a bit cognitively activating. A further increase in cognitive activation seems to have no additional effect. However, a very strong positive attitude seems to be related to a slightly lower performance in science.

In contrast, cognitive activation plays a key role in reading achievement: In highly cognitively activating environments, students perform almost equally well independent of their attitude toward school. As cognitive activation declines, students‘ reading performance becomes highly dependent on their attitude toward school.

### Conclusion
Students benefit a bit from learning in cognitively activating math lessons, whereas cognitive activation does not matter very much in science lessons as long as a basic activation is ensured. On the contrary however, cognitive activation can almost completely compensate for differences in attitude toward school in reading lessons.

In this code excerpt, we illustrate the approach of response surface analysis with data from PISA 2012-2013 (campus file) for three different dependent variables: achievement in math, science, and reading.

library(dplyr) # only for data preparation
library(sjmisc) # only for data preparation
library(RSA) # for the response surface analysis
library(latticeExtra) # for combining several lattice-based plots into one

# Import data ——————————————————————

# Calculate scale means ——————————————————–
pisa_2012_2013_data %>%
as_tibble() %>% # not necessary, just for better output of data
select((starts_with(„attitud_“) | starts_with(„cognact_“))
& ends_with(„_t2“)) %>%
mutate(across(.cols = everything(), .fns = as.numeric)) %>% # convert factors
rec((contains(„_a_“) | contains(„_b_“)), rec = „rev“) %>% # reverse items
row_means((starts_with(„attitud_“) & ends_with(„_t2“)),
n = 1, var = „Attitude_Toward_School_T2“) %>%
row_means((starts_with(„cognact_“) & ends_with(„_t2“)),
n = 1, var = „Cognitive_Activation_T2“) %>%
select(Attitude_Toward_School_T2, Cognitive_Activation_T2) %>%
bind_cols(pisa_2012_2013_data, .) -> pisa_2012_2013_data

# Perform response surface analyses ——————————————–
model.results.math <- RSA(ma_wle_t2 ~ Attitude_Toward_School_T2 * Cognitive_Activation_T2,
data = pisa_2012_2013_data,
center = „pooled“,
missing = „listwise“)

model.results.science <- RSA(sci_wle_t2 ~ Attitude_Toward_School_T2 * Cognitive_Activation_T2,
data = pisa_2012_2013_data,
center = „pooled“,
missing = „listwise“)

model.results.reading <- RSA(rea_wle_t2 ~ Attitude_Toward_School_T2 * Cognitive_Activation_T2,
data = pisa_2012_2013_data,
center = „pooled“,
missing = „listwise“)

# Comment:
# deleting missing values „listwise“ might not be the best way, but this is a
# visualization challenge with a campus file, right? 😉

# Calculate plots ————————————————————–
p_ma <- plot(model.results.math,
# points = list(color = „White“),
xlab = „Attitude Toward School“,
ylab = „Cognitive Activation“,
zlab = „Math Achievement“,
main = „Different Interaction Effects for Different Outcomes: Response Surface Analysis of PISA Data from 2013“,
cex.tickLabel = 1.5,
cex.axesLabel = 2,
cex.main = 3)

p_sci <- plot(model.results.science,
# points = list(color = „White“),
xlab = „Attitude Toward School“,
ylab = „Cognitive Activation“,
zlab = „Science Achievement“,
main = „Different Interaction Effects for Different Outcomes: Response Surface Analysis of PISA Data from 2013“,
cex.tickLabel = 1.5,
cex.axesLabel = 2,
cex.main = 3)