I want to conduct an (example) experiment. I have 3 skinny rats and 3 fat rats. First, I give them a standardized meal and will take blood samples to measure levels of protein "X" before and after this meal. Second, all rats undergoes weight loss for 1 week. Third, after weight loss, I again give them a standardized meal and will take blood samples to measure levels of protein "X" before and after this meal.
Here is the design:
rats <- factor(rep(rep(1:3,each=2),4)) # 3 rats in each group
weightloss <- factor(rep(c("Start", "End"), each=12), levels = c("Start","End"))
meal <- factor(rep(c("Before", "After"), 12), levels = c("Before","After"))
group <- rep(factor(rep(c("Skinny", "Fat"), levels = c("Skinny","Fat"), each=6)),2)
There are a few questions I want to answer:
1. The response in protein "X" levels in skinny mice before weight loss: Simple paired design
2. The response in protein "X" levels in skinny mice after weight loss: Simple paired design
3. The difference in response in protein "X" levels in skinny mice before vs. after weight loss: Interaction
4. The response in protein "X" levels in fat mice before weight loss: Simple paired design
5. The response in protein "X" levels in fat mice after weight loss: Simple paired design
6. The difference in response in protein "X" levels in fat mice before vs. after weight loss: Interaction
7. The difference in response in protein "X" levels in fat mice before vs. after weight loss different from the difference in response in protein "X" levels in skinny mice before vs. after weight loss: interaction of the interactions
I have no problems with comparisons 1:6, only 7 gives me trouble. Here is my attempt:
design <- model.matrix(~0+group:meal:weightloss+rats)
colnames(design)[4:11] <- gsub(colnames(design)[4:11], pattern=":", replacement=".")
library("caret")
findLinearCombos(design) # Column 11 gives me a problem
# The intuitive way is to write this interaction of interactions formula as follows:
((groupFat.mealAfter.weightlossEnd-groupFat.mealBefore.weightlossEnd)-((groupFat.mealAfter.weightlossStart-groupFat.mealBefore.weightlossStart))-((groupSkinny.mealAfter.weightlossEnd-groupSkinny.mealBefore.weightlossEnd)-(groupSkinny.mealAfter.weightlossStart-groupSkinny.mealBefore.weightlossStart)))
However, I am not quite sure how to re-write it to remove the linear redundant column 11? Could it be like this:
design <- design[,!grepl("Before", colnames(design))] # get to full rank
# Then the interaction of interactions is the following:
(groupFat.mealAfter.weightlossEnd-groupSkinny.mealAfter.weightlossEnd)-(groupFat.mealAfter.weightlossStart-groupSkinny.mealAfter.weightlossStart)
Correct?
Wow. That was advanced, and beautiful! I am glad this gives the same result as my approach, but I learned something new. Thank you!