Jamie Lynn Taxer
Jamie Lynn Taxer

Reputation: 1

Probe interactions from regression with user defined contrasts

I am struggling examining significant interactions from a linear regression with user defined contrast codes. I conducted an intervention to improve grades with three treatment groups (i.e., mindset, value, mindset plus value) and one control group and would now like to see if there is an interaction between specific intervention levels and various theoretically relevant categorical variables such as gender, free lunch status, and a binary indicator for having a below average gpa the two previous semesters, and relevant continuous variables such as pre-intervention beliefs (Imp_pre.C & Val_pre.C in the sample dataframe below). The continuous moderators have been mean centered.

#subset of dataframe
mydata <- structure(list(cond = structure(c(1L, 2L, 3L, 3L, 2L, 3L,     1L,2L, 2L, 1L), contrasts = structure(c(-0.25, 0.0833333333333333,0.0833333333333333, 0.0833333333333333, -1.85037170770859e-17,-0.166666666666667, -0.166666666666667, 0.333333333333333, 0,-0.5, 0.5, 0), .Dim = 4:3, .Dimnames = list(c("control", "mindset","value", "MindsetValue"), NULL)), .Label = c("control", "mindset","value", "MindsetValue"), class = "factor"), sis_mp3_gpa = c(89.0557142857142,91.7514285714285, 94.8975, 87.05875, 69.9928571428571, 78.0357142857142,87.7328571428571, 83.8925, 61.2271428571428, 79.8314285714285), sis_female = c(1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L), low_gpa_m1m2 = c(0,0, 0, 0, 1, 1, 0, 0, 1, 0), sis_frpl = c(0L, 1L, 0L, 0L, 1L,1L, 1L, 1L, NA, 0L), Imp_pre.C = c(1.80112944983819, -0.198870550161812,1.46112944983819, -0.198870550161812, 0.131129449838188, NA,-0.538870550161812, 0.131129449838188, -0.198870550161812, -0.198870550161812), Val_pre.C = c(-2.2458357581636, -2.0458357581636, 0.554164241836405,0.554164241836405, -0.245835758163595, NA, 0.554164241836405,0.554164241836405, -2.0458357581636, -1.64583575816359)), row.names = c(323L,2141L, 2659L, 2532L, 408L, 179L, 747L, 2030L, 2183L, 733L), class = "data.frame")

Since I'm only interested in specific contrasts, I created the following user defined contrast codes.

mat = matrix(c(1/4, 1/4, 1/4, 1/4, -3, 1, 1, 1, 0, -1, -1, 2, 0,
mymat = solve(t(mat))
mymat
my.contrasts <- mymat[,2:4]
contrasts(mydata$cond) = my.contrasts

I'm testing the following model:

#model
model1 <- lm(sis_mp3_gpa ~ cond +
               sis_female*cond +
               low_gpa_m1m2*cond + 
               sis_frpl*cond +
               Imp_pre.C*cond + 
               Val_pre.C*cond + 
               Imp_pre.C + Val_pre.C +
               low_gpa_m1m2 + sis_female +
               sis_frpl , data = mydata)
summary(model1)

In the full data set there is a significant interaction between contrast two (comparing mindset plus value to mindset & value) and previous value beliefs (i.e., Val_pre.C) and between this contrast code and having a low gpa the 2 previous semesters. To interpret significant interactions I would like to generate predicted values for individuals one standard deviation below and above the mean on the continuous moderator and the two levels of the categorical moderator. My problem is that when I have tried to do this the plots contain predicted values for each condition rather than collapsing the mindset and value condition and excluding the control condition. Also, when I try to do simple slope analyses I can only get pairwise comparisons for all four conditions rather than the contrasts I'm interested in.

How can I plot predicted values and conduct simple slope analyses for my contrast codes and a categorical and continuous moderator?

Upvotes: 0

Views: 256

Answers (1)

Russ Lenth
Russ Lenth

Reputation: 6770

This question cannot be answered for two reasons: (1) the code for mat is incomplete and won't run, and (2) the model seriously over-fits the subsetted data provided, resulting in 0 d.f. for error and no way of testing anything.

However, here is an analysis of a much simpler model that may show how to do what is needed.

> simp = lm(sis_mp3_gpa ~ cond * Imp_pre.C, data = mydata)

> library(emmeans)
> emt = emtrends(simp, "cond", var = "Imp_pre.C")

> emt   # estimated slopes
 cond    Imp_pre.C.trend    SE df lower.CL upper.CL
 control            1.97  7.91  3    -23.2     27.1
 mindset            1.37 42.85  3   -135.0    137.7
 value              4.72 12.05  3    -33.6     43.1

Confidence level used: 0.95 

> # custom contrasts of those slopes
> contrast(emt, list(c1 = c(-1,1,0), c2 = c(-1,-1,2)))
 contrast estimate   SE df t.ratio p.value
 c1         -0.592 43.6  3 -0.014  0.9900 
 c2          6.104 49.8  3  0.123  0.9102 

Upvotes: 0

Related Questions