Entering edit mode
Hello!
If I have something akin to the design matrix below which contains two factors and a continuous response variable:
set.seed(1)
library(limma)
data <- data.frame(treatment = factor(c(rep("control", 15),rep("treatment", 15))),
time = factor(rep(c(rep("time1", 5),rep("time2", 5),rep("time3", 5)),2)),
response = as.numeric(sample.int(50, 30, replace = TRUE)),
location = sample(LETTERS[1:5],30, replace = T)
)
data$Treatment_Time <- paste(data$treatment, data$time, sep = "_")
dm <- model.matrix(~Treatment_Time*response+location, data)
colnames(dm) <- gsub("Treatment_Time", "", colnames(dm))
and will produce the coefficients for the following:
(Intercept)
control_time2
control_time3
treatment_time1
treatment_time2
treatment_time3
response
locationB
locationC
locationD
locationE
control_time2:response
control_time3:response
treatment_time1:response
treatment_time2:response
treatment_time3:response
Is taking the coefficients for treatment_time1:response
essentially treatment_time1:response - control_time1:response
? Since response is continuous I include an intercept but expected an interaction term for the control at time1 with response to make the comparison.
I hope someone can help,
Thanks!