[R] ANOVA vs REML approach to variance component estimation

From: Adaikalavan Ramasamy <ramasamy_at_cancer.org.uk>
Date: Sat 11 Jun 2005 - 03:35:02 EST


Can anyone verify my calculations below or explain why they are wrong ?

I have several animals that were measured thrice. The only blocking variable is the animal itself. I am interested in calculating the between and within object variations in R. An artificial example :

y <- c( 2.2, -1.4, -0.5,  # animal 1
       -0.3  -2.1   1.5,  # animal 2
        1.3  -0.3   0.5,  # animal 3
       -1.4  -0.2   1.8)  # animal 4

ID <- factor( rep(1:4, each=3) )
  1. Using the ANOVA method

  summary(aov( y ~ ID ))

              Df Sum Sq Mean Sq F value Pr(>F)
  ID           3  0.900   0.300  0.1207 0.9453
  Residuals    8 19.880   2.485               

=> within animal variation = 2.485
=> between animal variation = (0.300 - 2.485)/3 = -0.7283

I am aware that ANOVA can give negative estimates for variances. Is this such a case or have I coded wrongly ?

2) Using the REML approach

  library(nlme)
  lme( y ~ 1, rand = ~ 1 | ID)
   ....
  Random effects:
  Formula: ~1 | ID

          (Intercept) Residual
  StdDev: 0.01629769 1.374438

=> within animal variation = 1.374438^2 = 1.88908
=> between animal variation = 0.01629769^2 = 0.0002656147

Is this the correct way of coding for this problem ? I do not have access to a copy of Pinheiro & Bates at the moment.

Thank you very much in advance.

Regards, Adai



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jun 11 04:00:51 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:30 EST