[R] random and group arguments in lme

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Apr 13 14:13:57 CEST 2000


"Eusebio Arenal Gutiérrez" <use at eio.uva.es> writes:

> I want to fit the following model:
> 
> > aov.madera <- aov(tiempo~producto/panel, data = madera)
> > anova(aov.madera)
> Analysis of Variance Table
> 
> Response: tiempo
>                Df Sum Sq Mean Sq F value    Pr(>F)    
> producto        2 93.631  46.815 63.0511 4.304e-07 ***
> producto:panel  9 43.533   4.837  6.5144  0.001881 ** 
> Residuals      12  8.910   0.742                      
> ---
> Signif. codes:  0  `***'  0.001  `**'  0.01  `*'  0.05  `.'  0.1  ` '  1 
> 
> As panel is random I would need
> ["producto", "Mean Sq"]/["producto:panel", "Mean Sq"] in the cell
> ["producto", "F value"]
> and its p-value, that is
> 
> > 46.815/4.837
> [1] 9.67852
> > 2*pf(46.815/4.837, 2, 9, lower.tail=FALSE)
> [1] 0.01143266
> 
> How can I fit this model with lme function (of nlme)? What arguments have I
> to put in the random and group arguments?

Assuming that this is a 3x4x2 factorial layout, it would be easier to
use

summary(aov(tiempo~producto+Error(producto:panel), data = madera))

cf.

> pr<-gl(3,1,24)
> pa<-gl(4,3,24)
> y<-rnorm(24)
> summary(aov(y~pr+Error(pr:pa)))

Error: pr:pa
          Df Sum Sq Mean Sq F value  Pr(>F)  
pr         2 6.5870  3.2935  3.2109 0.08861 .
Residuals  9 9.2316  1.0257                  
---
Signif. codes:  0  `***'  0.001  `**'  0.01  `*'  0.05  `.'  0.1  ` '  1 

Error: Within
          Df  Sum Sq Mean Sq F value Pr(>F)
Residuals 12 16.6469  1.3872               


With lme() it seems to be tricky to do the pa:pr interaction
as a groping, but you might do

> pa<-gl(12,1,24)
> lme(y~pr,random=~1|pa)
Linear mixed-effects model fit by REML
  Data: NULL 
  Log-restricted-likelihood: -35.11024
  Fixed: y ~ pr 
(Intercept)         pr2         pr3 
  0.5753093  -0.3784748  -1.2511397 

Random effects:
 Formula: ~1 | pa
         (Intercept) Residual
StdDev: 1.669157e-53 1.110096

Number of Observations: 24
Number of Groups: 12 
> anova(lme(y~pr,random=~1|pa))
            numDF denDF   F-value p-value
(Intercept)     1    12 0.0200734  0.8897
pr              2     9 2.6726312  0.1227

Notice that this is not the same as the balanced analysis, since the
pa random effect would have a negative variance in this case.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list