R, lme: specifying random effects for mixed model of before-after-gradient analysis

1.1k views Asked by At

I'm trying to measure the biological impacts of an industrial development using a Before-After-Gradient approach. I am using a linear mixed model approach in R, and am having trouble specifying an appropriate model, especially the random effects. I've spent a lot of time researching this, but so far haven't come up with a clear solution--at least not one that I understand. I am new to LMM (and R for that matter) so would welcome any advice.

The response variables (for example, changes in abundance of key species) will be measured as a function of distance from the edge of impact, using plots established at fixed distances along multiple transects ("gradients") radiating out from the edge of the disturbance. Ideally, each plot would be sampled at multiple times both before and after the impact; however, for simplicity I'm starting by assuming the simplest case, where each plot is sampled once before and once after the impact. Assume also that the individual gradients are far enough apart that they can be considered spatially independent.

First, some simulated data. The effect here is linear instead of curvilinear, but you get the idea.

> str(bag)
'data.frame':   30 obs. of  5 variables:
 $ Plot    : Factor w/ 15 levels "G1-D0","G1-D100",..: 1 2 4 5 3 6 7 9 10 8 ...
 $ Gradient: Factor w/ 3 levels "1","2","3": 1 1 1 1 1 2 2 2 2 2 ...
 $ Distance: Factor w/ 5 levels "0","100","300",..: 1 2 3 4 5 1 2 3 4 5 ...
 $ Period  : Factor w/ 2 levels "After","Before": 2 2 2 2 2 2 2 2 2 2 ...
 $ response: num  0.633 0.864 0.703 0.911 0.676 ...
> bag
       Plot Gradient Distance Period   response
1     G1-D0        1        0 Before 0.63258749
2   G1-D100        1      100 Before 0.86422356
3   G1-D300        1      300 Before 0.70262745
4   G1-D700        1      700 Before 0.91056851
5  G1-D1500        1     1500 Before 0.67637353
6     G2-D0        2        0 Before 0.75879579
7   G2-D100        2      100 Before 0.77981992
8   G2-D300        2      300 Before 0.87714158
9   G2-D700        2      700 Before 0.62888739
10 G2-D1500        2     1500 Before 0.83217617
11    G3-D0        3        0 Before 0.87931801
12  G3-D100        3      100 Before 0.81931761
13  G3-D300        3      300 Before 0.74489963
14  G3-D700        3      700 Before 0.68984485
15 G3-D1500        3     1500 Before 0.94942006
16    G1-D0        1        0  After 0.00010000
17  G1-D100        1      100  After 0.05338171
18  G1-D300        1      300  After 0.15846741
19  G1-D700        1      700  After 0.34909588
20 G1-D1500        1     1500  After 0.77138824
21    G2-D0        2        0  After 0.00010000
22  G2-D100        2      100  After 0.05801157
23  G2-D300        2      300  After 0.11422562
24  G2-D700        2      700  After 0.34208601
25 G2-D1500        2     1500  After 0.52606733
26    G3-D0        3        0  After 0.00010000
27  G3-D100        3      100  After 0.05418663
28  G3-D300        3      300  After 0.19295391
29  G3-D700        3      700  After 0.46279103
30 G3-D1500        3     1500  After 0.58556186

As far as I can tell, the fixed effects should be Period (Before,After) and Distance, treating distance as continuous (not a factor) so we can estimate the slope. The interaction between Period and Distance (equivalent to the difference in slopes, before vs. after) measures the impact. I'm still scratching my head over how to specify the random effects. I assume I should control for variation among gradients, as follows:

result <- lme(response ~ Distance + Period + Distance:Period, random=~ 1 | Gradient, data=bag)

However, I suspect I may be missing some source of variation. For example, I'm not sure the above model controls for the re-sampling of individual plots before and after. Any suggestions?

1

There are 1 answers

0
John On BEST ANSWER

With one sample / gradient, as you have, there's no need to specify random effects or anything about the gradients. You can do this with a straight multiple regression. Once you have multiple measures in each gradient then you can use the model you've specified. Which is that there's an expected main effect of gradient on the intercept of the model but that the effects (slopes) of Distance, Period, and their interactions, should be fixed.

You could specify additional random effects if you expect there to be an appreciable amount of variability among gradients in your other predictors. I'm not sure how you do it in lme, or even if you can, but in lmer an example might be:

lmer(response ~ Distance * Distance:Period + (1 + Distance | Gradient), data=bag)

That would allow the Distance slope to have a fixed effect component and one that varied with gradient. You can look up further specification of random effects but hopefully you see the general idea and then you can decide how complex to make your model.