ANOVA & Orthogonal Constrasts

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

Yes, model1 is overparameterized. Have you tried running it without an intercept term?

model1 <- aov(Starter$`BW, g`~ Group - 1)

Thank you for the suggestion. However, I've tried and the result is this:

Call:
aov(formula = Starter$`BW, g` ~ Group - 1)

Residuals:
     Min       1Q   Median       3Q      Max 
-17.2222  -5.6713   0.0463   4.5833  12.8704 

Coefficients:
         Estimate Std. Error t value Pr(>|t|)    
GroupCON   245.28       2.55   96.20   <2e-16 ***
GroupA     241.30       2.55   94.64   <2e-16 ***
GroupB     241.39       2.55   94.67   <2e-16 ***
GroupC     236.93       2.55   92.92   <2e-16 ***
---
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.9991,	Adjusted R-squared:  0.999 
F-statistic:  8952 on 4 and 32 DF,  p-value: < 2.2e-16

I think there is still a problem, especially because the contrasts disappare in the output.

I think the problem isn't that you have 4 contrasts, because that's the maximum parameters you can fit, but it's that the 4 contrasts aren't linearly independent. The CONvsOthers is the same as the sum of the other three contrasts. The results of CONvsOthers is a linear combination of the results of the individual tests.

I solved the problem by using lsmeans package.
Thank you again for the help.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.