[R] Random structure of nested design in lme
Spencer Graves
spencer.graves at pdf.com
Sat Jul 22 20:03:46 CEST 2006
Have you considered the following:
anova(lme(NA.1~soiltype*habitat,random=~1|destination/origin))
This seems more closely to match the 'aov' command in your original
post. This model might be written in more detail as follows:
NA.1[s, h, i,j,k] = b0 + ST[s] + H[h] +
ST.H[s[i],j[j] j] + d[i] + o[i,j] + e[i,j,k]
where b0 = a constant to be estimated,
s = the soil type for that particular sample,
h = the habitat for that sample,
ST = soil type coefficients to be estimated subject to a constraint
that they sum to 0,
H = habitat coefficients to be estimated subject to the constraint
that they sum to 0,
ST.H = soil type by habitat interaction coefficients to be estimated
subject to constraints that ST.H[s,.] sum to 0 and ST.H[., h] also sum
to 0,
d[i] = a random deviation associated with each destination, assuming
the d's are all normal, independent, with mean 0 and unknown but
constant variance s2.d
o[i, j] = a random deviation associated with each destination /
origin combination, assuming the o's are all normal, independent, with
mean 0 and unknown variance s2.o,
and e[i,j,j] = the standard unknown noise term, normal, independent
with mean 0 and unknown variance s2.e.
The model you wrote includes nested noise terms for soil type and
habitat as well. These terms are not estimable, which makes the answers
garbage, but the 'lme' function does not check for replicates and
therefore sometimes gives garbage answers without warning.
To get more information from the fit, I suggest you first try
'methods(class="lme")', and review help pages associated with what you
see listed there.
Have you looked at Pinheiro and Bates (2000) Mixed-Effects Models in
S and S-Plus (Springer)? This is my all-time favorite reference on
Bates has been one of the leading original contributors in variance
components analysis and nonlinear estimation more generally for over 25
years. The 'nlme' package is the product of his work and the work of
many of his graduate students prior to 2000. The book, at least from my
perspective, is very well written. Moreover, the standard R
distribution includes files named "ch01.R", "ch02.R", ..., "ch06.R",
"ch08.R" with the R scripts accompanying each chapter in the book in
"~\library\nlme\scripts" under the R installation directory on your hard
drive, e.g. "D:\Program files\R\R-2.3.1\library\nlme\scripts", on my
computer. There are minor changes in the syntax in a few places between
the book and the current R implementation that make it impossible to get
some of the published answers. Using these script files increases the
likelihood that you will get essentially the book's answers and won't be
defeated by subtle typographical errors or by the difference between x^2
and I(x^2), for example.
If you would like further information from this listserver, please
submit another post, preferably including a "commented, minimal,
self-contained, reproducible code", as suggested in the posting guide
"www.R-project.org/posting-guide.html".
Hope this helps.
Spencer Graves
ESCHEN Rene wrote:
> Although I know it's not correct, this is what I tried in lme:
>
> anova(lme(NA.1~soiltype*habitat,random=~1|destination/habitat/origin/soiltype))
>
> # numDF denDF F-value p-value
> #(Intercept) 1 130 12.136195 0.0007
> #soiltype 1 130 15.099792 0.0002
> #habitat 1 10 0.699045 0.4226
> #soiltype:habitat 1 130 2.123408 0.1475
>
> René.
>
> -----Original Message-----
> From: Doran, Harold [mailto:HDoran at air.org]
> Sent: Wed 2006-07-19 13:53
> To: ESCHEN Rene; r-help at stat.math.ethz.ch
> Subject: RE: [R] Random structure of nested design in lme
>
> Can you provide an example of what you have done with lme so we might be able to evaluate the issue?
>
>> -----Original Message-----
>> From: r-help-bounces at stat.math.ethz.ch
>> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of ESCHEN Rene
>> Sent: Wednesday, July 19, 2006 7:37 AM
>> To: r-help at stat.math.ethz.ch
>> Subject: [R] Random structure of nested design in lme
>>
>> All,
>>
>> I'm trying to analyze the results of a reciprocal transplant
>> experiment using lme(). While I get the error-term right in
>> aov(), in lme() it appears impossible to get as expected. I
>> would be greatful for any help.
>>
>> My experiment aimed to identify whether two fixed factors
>> (habitat type and soil type) affect the development of
>> plants. I took soil from six random sites each of two types
>> (arable and grassland) and transplanted them back into the
>> sites of origin in such way that in each of the sites there
>> were six pots containing arable soil and six pots of
>> grassland soil, each containing a seedling.
>>
>> With aov(), I got the analysis as I expected, with habitat
>> type tested against destination site, and soil type tested
>> against origin site:
>>
>> summary(aov(response~soiltype*habitat+Error(destination+origin)))
>> #
>> #Error: destination
>> # Df Sum Sq Mean Sq F value Pr(>F)
>> #habitat 1 1.0000 1.0000 0.699 0.4226
>> #Residuals 10 14.3056 1.4306
>> #
>> #Error: origin
>> # Df Sum Sq Mean Sq F value Pr(>F)
>> #soiltype 1 1.77778 1.77778 11.636 0.006645 **
>> #Residuals 10 1.52778 0.15278
>> #---
>> #Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #
>> #Error: Within
>> # Df Sum Sq Mean Sq F value Pr(>F)
>> #soiltype:habitat 1 0.2500 0.2500 2.1774 0.1427
>> #Residuals 120 13.7778 0.1148
>>
>> However, when I try to replicate this analysis in lme, I am
>> unable to get the structure of the random factors (origin and
>> destination) correct. Does anyone have a suggestion how to
>> resolve this problem?
>>
>> Thanks in advance.
>>
>> René Eschen
>>
>> CABI Bioscience Centre Switzerland
>> Rue des Grillons 1
>> 2800 Delémont
>> Switzerland
>>
>> [[alternative HTML version deleted]]
>>
>>
>
>
> [[alternative HTML version deleted]]
>
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list