[R-sig-ME] Nested random factor
Douglas Bates
bates at stat.wisc.edu
Fri Jan 23 00:42:45 CET 2009
On Thu, Jan 22, 2009 at 5:28 PM, Renwick, A. R. <a.renwick at abdn.ac.uk> wrote:
> Thank you so much for your reply.
> Can I just check the labelling of my data regards you comment "ensure that each distinct site has a distinct label - that is,
> avoid "implicit nesting"".
You do have a distinct label for each site.
I hesitate to describe what I call "implicit nesting" because my point
is that it is not a good way to organize the data. However many
people use it, I think as a holdover from earlier techniques and
software. It would be a layout like
> Farm Site Sample period Abundance
> 1 1 1 10
> 2 1 1 3
> 3 1 1 2
...
> 1 2 1 2
> 2 2 1 3
> 3 2 1 22
That is, the two sites within a farm are always labeled '1' and '2'
and we are supposed to somehow know that Site '1' in Farm '1' is not
in any way related to Site '1' in Farm '2'.
If you didn't plan to organize your data that way then ignore the
whole issue. You have 14 sites with 14 distinct labels so everything
will work out.
> for example:
> 7 farms, 14 margins (2 margins in each farm). All margins sampled 4 times
> DUMMY DATA:
>
> Random effect specified as (1|Farm/Site)
>
> Farm Site Sample period Abundance
> 1 1 1 10
> 2 2 1 3
> 3 3 1 2
> 4 4 1 6
> 5 5 1 13
> 6 6 1 11
> 7 7 1 12
> 1 8 1 2
> 2 9 1 3
> 3 10 1 22
> 4 11 1 1
> 5 12 1 33
> 6 13 1 2
> 7 14 1 13
> 1 1 2 13
> 2 2 2 12
> 3 3 2 11
> 4 4 2 3
> 5 5 2 6
> 6 6 2 5
> 7 7 2 4
> 1 8 2 12
> 2 9 2 24
> 3 10 2 25
> 4 11 2 3
> 5 12 2 22
> 6 13 2 23
> 7 14 2 8
>
> Many many thanks
> Anna
>
> ________________________________________
> From: dmbates at gmail.com [dmbates at gmail.com] On Behalf Of Douglas Bates [bates at stat.wisc.edu]
> Sent: 22 January 2009 23:14
> To: Renwick, A. R.
> Cc: r-sig-mixed-models at r-project.org
> Subject: Re: [R-sig-ME] Nested random factor
>
> On Thu, Jan 22, 2009 at 11:10 AM, Renwick, A. R. <a.renwick at abdn.ac.uk> wrote:
>
>> I am running a LME with a nested random factor using the 'nlme' package and ahave a query interpreting the varince of the netsed random factor.
>> My data contains samples from 7 farms, and within these farms I sampled at 2 sites. The total number of sites was therefore 14, of which I sampled 4 times.
>
>> I therefore have used the following random effect:
>> 1|Farm/Site
>
>> My final model is below:
>
>> mrem<-lme(log(Nhat+1)~ Width + crop+sess +Width:sess ,random=~1|Farm/Site,data=all, method="REML",correlation=NULL,weights=varIdent(form=~1|Group3))
>
>> summary(mrem)
>
>> #part of the summary
>> #Linear mixed-effects model fit by REML
>> # Data: all
>> # AIC BIC logLik
>> # 106.2403 136.8477 -34.12013
>> #
>> #Random effects:
>> # Formula: ~1 | Farm
>> # (Intercept)
>> #StdDev: 0.1597866
>> #
>> # Formula: ~1 | Site %in% Farm
>> # (Intercept) Residual
>> #StdDev: 0.2458009 0.928392
>> #Number of Observations: 51
>> #Number of Groups:
>> # Farm Site %in% Farm
>> # 7 14
>
>> I would like to check that I am interpreting the random effect correctly.
>> 1) The std dev of the between-farm variance is 0.16
>
> That phrase is a bit peculiar. I think I would say either,
>
> The standard deviation of the random effect for farm is 0.16
>
> or
>
> The between-farm variance is (0.16)^2
>
>> 2) The std dev of the between-site variance is 0.25
>
> In your terminology I would say, "The variance between sites within
> farms is (0.25)^2."
>
>> 3) The std dev of the within-site variance is 0.93.
>
> Again, I would phrase this as "The variance within sites is (0.93)^2."
>
>> However, I think I may have missed out the 'nesting' part,i.e the variance within sites within farms, and the variance between sites within farms.
>
> Because sites are nested within farms, "within site" is the same as
> "within site, within farms" and "between sites within farms" is your
> line 2) above. If you were to eliminate the random effect for farm
> (and ensure that each distinct site has a distinct label - that is,
> avoid "implicit nesting") then you would estimate a "between site"
> variance.
>
> I'm not surprised that this seems confusing. I certainly found all
> the material on variance components with mean squares and expected
> mean squares to be confusing when I was first exposed to it. I vowed I
> would stay as far away from that type of statistics as I could because
> it was just so tedious and messy. Obviously I didn't succeed in
> staying away from it.
>
>> Any help to clarify this point would be much appreciated.
>>
>> Many thanks,
>> Anna
>>
>> Anna Renwick
>> Institute of Biological & Environment Sciences
>> University of Aberdeen
>> Zoology Building
>> Tillydrone Avenue
>> Aberdeen
>> AB24 2TZ
>>
>>
>> The University of Aberdeen is a charity registered in Scotland, No SC013683.
>>
>> _______________________________________________
>> R-sig-mixed-models at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>
>
>
> The University of Aberdeen is a charity registered in Scotland, No SC013683.
>
More information about the R-sig-mixed-models
mailing list