[R-sig-eco] query on lme model with complicated sampling design

Soner Iscan soner.iscan2 at gmail.com
Tue Mar 12 21:08:19 CET 2013


Dear R users,

I am trying to fit a linear mixed model (lme) to some soil moisture
data collected using a rather complicated design. The data were
collected across four habitats over the course of 44 months. Three
replicates were done for each habitat and, within each habitat, soil
moisture was measured at 16 different depths. I am interested in: i)
testing for a difference in soil moisture across habitats ii) testing
for a difference in moisture across different soil depths and iii)
testing for a difference in soil moisture across seasons. Below an
idea on how I would analyze the dataset with some pseudo code, sample
data and some doubts on what to do. Any advice/help would be greatly
appreciated!

# read data into R
dat<-read.csv("http://dl.dropbox.com/u/152465945/datsoil.csv")


# show the structure of the data frame

str(dat)

'data.frame':	10291 obs. of  6 variables:
 $ soilmoisture   : num  21.1 18.7 16.4 13.2 8.3 5.1 5.3 5.7 5.4 4.9 ...
 $ depth    : int  10 20 30 40 50 60 70 80 90 100 ...
 $ habitat  : Factor w/ 4 levels "hab1","hab2",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ year.f   : Factor w/ 5 levels "y1","y2","y3",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ season   : Factor w/ 4 levels "aut","spr","sum",..: 2 2 2 2 2 2 2 2 2 2 ...
 $ replicate: int  1 1 1 1 1 1 1 1 1 1 ...


# my  idea on how model should be fit
mod<-lme(soilmoisture~habitat+depth+season/year +AR1+(1|replicate)

where:

i) including the variable habitat would allow me to test for a
difference in in soil moisture across habitat (see question i above)

ii) including the variable depth would allow me to test for a
difference in soil moisture across depths (see question ii above).
Given that depth is expressed in cm would you advice me to keep it as
it is? I guess that if the variable was statistically significant this
would tell that depth had an effect on soil humidity i.e. there would
be a significant difference.

ii) including the variable season would allow me to test for a
difference in soil moisture across seasons (see questions iii above).
Is it plausible to nest season within year? Mind you that the data was
collected over different years.

iii) including an AR1 structure (or something similar) would allow me
to account for serial autocorrelated observations between months
(highly present by the way). Is this correct? Should also try to
account for serial autocorrelation between years, if present?

iv) i would like to include a random effect to allow observations
within depths to be correlated (given that they are not independent).
I am not sure whether the above pseudo code is right. The observations
within various depths should are not independent, but only within the
same habitat and month. Should I have a nested random effect
1|replicate/habitat/month instead?

apologies for the total beginner question

thanks in advance!

Best wishes,

Soner



More information about the R-sig-ecology mailing list