Hello everyone,
I'd be grateful if you could help me. I'd like to make orthogonal constrasts after performing an ANOVA. I'm dealing with 4 treatments (i.e. Control-CON, A, B, and C). The contratst I'd like to carry out are:
- CON vs A+B+C
- CON vs A
- CON vs B
- CON vs C
Group <- ordered(Group, levels = c("CON", "A", "B", "C"))
CONvsOthers <- c(-3,1,1,1)
CONvsA <- c(-1,1,0,0)
CONvsB <- c(-1,0,1,0)
CONvsC <- c(-1,0,0,1)
mat <- cbind(CONvsOthers, CONvsA, CONvsB, CONvsC)
contrasts(Group, 4) <- mat
model1 <- aov(Starter$`BW, g`~ Group)
summary.lm(model1, split=list(Group=list("CONvsOthers", "CONvsA",
"CONvsB", "CONvsC" )))
### The output is
Call:
aov(formula = Starter$`BW, g` ~ Group)
Residuals:
Min 1Q Median 3Q Max
-17.2222 -5.6713 0.0463 4.5833 12.8704
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 241.223 1.275 189.213 <2e-16 ***
GroupCONvsOthers -4.293 2.208 -1.944 0.0607 .
GroupCONvsA 4.366 3.606 1.211 0.2348
GroupCONvsB 4.459 3.606 1.236 0.2253
GroupCONvsC NA NA NA NA
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 7.649 on 32 degrees of freedom
Multiple R-squared: 0.1437, Adjusted R-squared: 0.06338
F-statistic: 1.789 on 3 and 32 DF, p-value: 0.169
The 4th contrast (i.e. CON vs C) has not been done. Is it due to "Group" is a 4-level factor and, therefore, the maximum number of constrasts can be only 3?
I've also tried with this code:
model2 <- aov(Starter$`BW, g` ~ Group)
library(gmodels)
cmat <- rbind("CONvsA" = CONvsA,
"CONvsB" = CONvsB,
"CONvsC" = CONvsC)
CONvsOthers <- rbind("CONvsOthers" = CONvsOthers)
fit.contrast(model2, Group, CONvsOthers)
fit.contrast(model2, Group, cmat)
### The output is
> fit.contrast(model2, Group, CONvsOthers)
Estimate Std. Error t value Pr(>|t|)
GroupCONvsOthers -16.21783 8.832627 -1.836127 0.07564535
attr(,"class")
[1] "fit_contrast"
> fit.contrast(model2, Group, cmat)
Estimate Std. Error t value Pr(>|t|)
GroupCONvsA -3.981481 3.605905 -1.104156 0.27775932
GroupCONvsB -3.888889 3.605905 -1.078478 0.28888323
GroupCONvsC -8.347458 3.605905 -2.314941 0.02718589
attr(,"class")
[1] "fit_contrast"
Despite the P values slightly changed, at least I was able to make all the 4 constrasts (even if separately).
If it was feasible, would you show me a way to concurrently perform all the 4 contrasts?
I whish someone could give me some tips.
Thanks in advance!
Giorgio