[R-sig-eco] Appropriate mixed model?

Dunbar, Michael J. mdu at ceh.ac.uk
Fri Sep 16 11:58:43 CEST 2011


Hi Rob

As it stands your model won't really do what you are expecting.

Start with a model like this:

fish.mod1<-lmer(fishsize ~ pH + landuse + conductivity + (1 | subcatchment), data=mydata)

You don't say whether you have multiple samples within each subcatchment + year combination, or whether your temporal replication is only between years. If latter then the above model is fine, the residual represents unexplained variation between years+subcatchments. If you have both within and among year variation then try

fish.mod1<-lmer(fishsize ~ pH + landuse + conductivity + (1 | subcatchment/year), data=mydata)

Year needs to be a factor here and you need to think whether you have enough data (years) to make it a sensible random effect.

Depending on whether your explanatory variables (fixed effects) vary through time or not, they will hopefully explain some of the variance at the appropriate matching level of your random effects. E.g. if land use is just one value for each subcatchment then it can only explain away variance at the subcatchment level. If pH is measured for each individual sample then it can potentially explain variance both among and within subcatchments. You can look visually at how much variance is being explained by individual terms by fitting the model with and without them.

When you start putting fixed effects to the left of the | in the random effects specification you are doing something entirely different. For a continuous variable such as pH, you are allowing the fishsize - pH relationship to vary by subcatchment. This is called a random slope. This could of course be the case but it makes sense to have some a-priori idea that this is a sensible interaction to test. For a categorical variable to go on the left then it's a categorical interpretation of the random slope idea. This can be hard to get to grips with, and you need to think carefully about how to code the categorical variable. This is not something to look into if you are just getting started with mixed models. 

If you think there could be common year to year variation across the subcatchments, e.g. as might be caused by some common climatic factor then you can fit a model like this, again providing you have sufficient years:

fish.mod1<-lmer(fishsize ~ pH + landuse + conductivity + (1 | subcatchment) + (1|year), data=mydata)

Regards
Mike


-----Original Message-----
From: r-sig-ecology-bounces at r-project.org [mailto:r-sig-ecology-bounces at r-project.org] On Behalf Of Briers, Rob
Sent: 16 September 2011 10:25
To: r-sig-ecology at r-project.org
Subject: [R-sig-eco] Appropriate mixed model?

Dear R-sig-ecology list members,

I've got a dataset of mean fish sizes across a large number of sites within a river system. I am trying to determine the relative significance of variation at the level of major tributaries (the river can be split into a number of subcatchments) compared to variation linked to more local factors (continuous variables such as pH, conductivity etc., along with some categorical variables such as local landuse as well). Fish and environmental data are from the same sites.

I had thought of approaching this using lmer to fit a random effects model of the form:

fish.mod1<-lmer(fishsize ~ 1 + (1 + pH + landuse + conductivity (etc..) | subcatchment))

and then examining the contributions to total variance.  Does this seem an appropriate way to proceed? I have gone round in circles with various options for a few days and thought I would get a broader opinion.
There is the added complication that data have been collected over a number of years, so ideally I would like to account for between-year variation as well. Is this simply the case of adding year as nested variable after subcatchment:

i.e. fish.mod2<-lmer(fishsize ~ 1 + (1 + pH + landuse + conductivity (etc..) | subcatchment/year))

Any advice would be appreciated!

Cheers,

Rob
_________________________________________
Dr Rob Briers
School of Life, Sport and Social Sciences
Edinburgh Napier University
Sighthill Campus
Edinburgh
EH11 4BN
Tel: +44(0)-131-455-2503
Fax: +44(0)-131-455-2291



Edinburgh Napier University is one of Scotland's top universities for graduate employability.  93.2% of graduates are in work or further study within six months of leaving. The university is also proud winner of the Queen's Anniversary Prize for Higher and Further Education 2009, awarded for innovative housing construction for environmental benefit and quality of life.

This message is intended for the addressee(s) only\ and ...{{dropped:14}}



More information about the R-sig-ecology mailing list