[R] [OFF] Nested or not nested, this is the question.

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Wed Apr 9 22:03:20 CEST 2003


"Ronaldo Reis Jr." <chrysopa at insecta.ufv.br> writes:

> I have 12 plots in 4 sizes in 3 replicates (4*3 = 12)
> In each plot I put 2 species (A and B) to reproduce.
> After a period I make samples in each board and count the number of 
> individuals total (tot) and individuals A and B (nsp). Others individuals 
> excepts A and B are in total of individuals.
> 
> This make a dataset with the 24 lines and not 12. Its smell pseudoreplication 
> in a nested design, OK?
> 
> I need to know:
> 
> the species are different in proportion?
> 
> the size affect the species's proportion?
> 
> existe interaction between size and species?
> 
> I make the analysis.
> 
> > m.lme <- lme(nsp/tot~size*specie,random=~1|size/specie)
> > anova(m.lme)
>             numDF denDF  F-value p-value
> (Intercept)     1    16 374.7121  <.0001
> size            1     2  37.8683  0.0254
> specie          1     2  18.2036  0.0508
> size:specie     1     2   9.3203  0.0926
> > 
> 
> This is the correct mean to make this analysis?
> 
> or
> 
> > m.lme <- lme(nsp/tot~size*specie,random=~1|plot/specie)
> > anova(m.lme)
>             numDF denDF  F-value p-value
> (Intercept)     1    10 579.8853  <.0001
> size            1    10  58.6030  <.0001
> specie          1    10  59.5235  <.0001
> size:specie     1    10  30.4760   3e-04
> > 
> 
> or neither?


Neither. First of all, you have numDF = 1 for things that have more
than two levels, so you forgot to make them factors.

reis$plot<-factor(reis$plot)
reis$size<-factor(reis$size)
reis$specie<-factor(reis$specie)

Then you seem to be needing something that describes the replication,
and you're not actually telling us, but if I guess that plots 1-4 is
the 1st replication and 5-8 and 9-12 are the others, then this should
work:

reis$repl <- factor((as.numeric(reis$plot)-1)%/%4+1)
table(reis$plot,reis$repl) # just to check

now you can do 

anova(lme(nsp/tot~size*specie,random=~1|repl/plot,data=reis))

and have

            numDF denDF   F-value p-value
(Intercept)     1     8 207.18935  <.0001
size            3     6  94.58027  <.0001
specie          1     8  57.14293   1e-04
size:specie     3     8  10.28573   4e-03

or, as I'd prefer in a balanced study:

summary(aov(nsp/tot~specie*size+Error(repl+plot),data=reis))

Error: repl
          Df   Sum Sq  Mean Sq F value Pr(>F)
Residuals  2 0.027708 0.013854

Error: plot
          Df   Sum Sq  Mean Sq F value    Pr(>F)
size       3 0.305417 0.101806   94.58 1.927e-05 ***
Residuals  6 0.006458 0.001076
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

Error: Within
            Df   Sum Sq  Mean Sq F value    Pr(>F)
specie       1 0.041667 0.041667  57.143 6.551e-05 ***
specie:size  3 0.022500 0.007500  10.286   0.00404 **
Residuals    8 0.005833 0.000729
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

(Error(repl/plot) actually works too because repl:plot is the same as plot)

This gets a little confusin because "repl" is a coarsening of "plot".
It may be easier with a within-repl numbering, which you can get by
noting that plot is equivalent to repl:size

anova(lme(nsp/tot~size*specie,random=~1|repl/size,data=reis))
summary(aov(nsp/tot~specie*size+Error(repl/size),data=reis))

-- 
   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



More information about the R-help mailing list