Dear all,

Thank you for your answers.

The samples are uniquely labelled, so when I write (1|location) +
(1|sample), they do not represent crossed random effects but nested random
effects.

For the number of levels for the factor Ť location ť, it's true that 4
levels is low to estimate a variance. I decided to treat location as a
random factor and not as a fixed effect because we are more interested in
variations among locations rather than the specific effects of each
location. Moreover, the 4 locations in our dataset represent a subset of a
larger set (11 locations), and we would like to generalize the results to
the other (non-sampled) locations.

However, even if the 4 locations are representative to the overall
locations, they haven't been selected at random, but because of technical
constraints.

I just had a talk with the person carrying out the whole experiment and
there may be other experiments at other locations within the next months. I
should therefore maybe treat location as a fixed factor, as you suggested.

Thanks a lot for your advices


2014-03-19 18:57 GMT+04:00 Ben Bolker <bbolker@gmail.com>:

> On 14-03-19 10:46 AM, Seth Bigelow wrote:
> > Well -- I don't know about the 'correct' model, but you might consider
> two
> > ideas. First, the variance among samples might differ according to
> location.
> > If so, you would get a better model by nesting sample within location,
> e.g.,
> > using the statement (1|location/sample), rather than (1|location) +
> > (1|sample). You can test whether this model is better with likelihood
> ratio
> > tests, i.e., anova(UnNestedmodel,NestedModel).
>
>   (1|location/sample) is equivalent to (1|location)+(1|location:sample).
>  If the samples are uniquely labeled (e.g. A1, A2, A3, B1, B2, B3, ...
> rather than 1, 2, 3, 1, 2, 3,) then these are *also* equivalent to
> (1|location)+(1|sample).  If they are not uniquely labeled then
> (1|location)+(1|sample) represents crossed random effects, which you
> probably *don't* want unless there is something that makes the first
> sample in every location the same.  (lme can't do crossed random effects
> in this way.)
>
> >
> > Second, you probably want to account for serial autocorrelation in
> samples
> > taken from the same location, repeatedly over time -- i.e. in the 'week'
> > variable. I've done this in SAS but never mastered the syntax in
> nlme/lme4.
>
>   lme4 can't do this, you would need lme with e.g.
> correlation=corAR1(formula=~week), although the uneven sampling of weeks
> could be problematic.
>
> >
> > Good luck
> > -Seth
> >
> >
> >
> > -----Original Message-----
> > From: r-sig-mixed-models-bounces@r-project.org
> > [mailto:r-sig-mixed-models-bounces@r-project.org] On Behalf Of sandrine
> le
> > squin
> > Sent: Wednesday, March 19, 2014 3:01 AM
> > To: r-sig-mixed-models@r-project.org
> > Subject: [R-sig-ME] nested random factor
> >
> > Dear all,
> >
> > I'm using lmer from lme4 package but I am not sure of what I'm doing.
> >
> > The dataset has the following variables :
> > - Treatment (fixed, 3 levels)
> > - Location (fixed, 4 levels)
> > - Sample (random, 5 levels). 5 samples are taken in each location
> (randomly)
> > - Subsample (random, 3 levels). 3 subsamples are taken in each sample.
> One
> > treatment is assigned (randomly) to one of the subsample.
> >
> > The study was conducted every Wednesday during 15 weeks in 2013, from
> week
> > 32 to week 47 (no observations for week 33).
> >
> > For the first location, samples are taken weeks 32, 36, 39, 42 and 49.
> > For the second location, samples are taken the week 46.
> > For the third location, samples are taken weeks 35, 38, 41 and 44.
> > For the 4th location, samples are taken week 34, 37, 40, 43, 47.
> >
> > For each location* i*, week *j(i)*, sample* k(ij)* and treatment *l*, the
> > "richness in sugar" of each subsample has been recorded.
> > The aim of the study is to see if there is an effect of the factor
> > "treatment" on the response "richness".
> >
> > I am new in mixed model so I did some research but I am a little bit
> > confused with the sampling design.
> >
> > I consider "location", "week" and "sample" as random factor, with sample
> > nested in week nested in location.
> > To avoid implicitly nested representations, "sample" has been recoded
> > (factor with 75 levels (5 samples*15 weeks)).
> >
> > I write in R:
> > lmer(richness ~ treatment + (1|location) + (1|week) + (1|sample), data =
> > mydata)
>
>   You said above the location and treatment are fixed: did you mean
> location was random?
>
>   I would use
>
>  richness ~ treatment + (1|location/week/sample)
>
> since within any given week samples are only taken in one location.
>
> 4 levels for location is a little low for reliable estimation of random
> effects, so you might consider
>
>  Since the treatments are replicated within locations, weeks,
> treatments, etc., you might need to consider
> (treatment|location/week/sample), although that might be overfitting the
> model ...
>
>
> >
> > Is my model correct ?
> >
> > Thank you for your help
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-mixed-models@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> >
> > _______________________________________________
> > R-sig-mixed-models@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> >
>
>

	[[alternative HTML version deleted]]

