[R-sig-eco] Appropriate mixed model?

Briers, Rob R.Briers at napier.ac.uk
Fri Sep 16 14:44:30 CEST 2011


Mike,

Thanks for the advice - I had started off with something similar to what you specified and as I read around a bit I got more confused and started to move effects around.  I have not really used mixed models before, so forgive any basic mistakes in interpretation!

Just to clarify, and make sure that I understand properly.

There are multiple samples collected from the different subcatchments, but in different years (so parts of the catchment were surveyed in one year, and other parts the following year etc.).  Each site was only visited once, so there is no temporal pseudoreplication at this level.  Sites have been surveyed over 9 years, and between 100-450 sites sampled per year.

In this case the model with the year included would seem to be most appropriate, but probably as a separate term because it is likely to affect all catchments equally i.e.

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

In terms of comparing the models, then initially it is presumably a case of fitting with and without a given fixed effect and comparing the fit (using ML estimation and then anova to compare) to simplify the model.

To determine what effect the random subcatchment effect on its own has compared to the fixed effects, would it be the case of fitting:

fish.mod2<-lmer(fishsize ~1 + (1|subcatchment))

and comparing this to the model with the fixed effects in?

If this is correct (?) then moving on to the random slopes situation, if pH was included as a fixed effect, and also to the left of the | then would comparing this model to a model with pH only as a fixed effect allow you to establish the extent to which fishsize~pH relationships vary between subcatchments as opposed to assuming a single global relationship as implied by the fixed effect.

Apologies if any of this is not clear - it is Friday!

Cheers,

Rob


-----Original Message-----
From: Dunbar, Michael J. [mailto:mdu at ceh.ac.uk] 
Sent: 16 September 2011 10:59
To: Briers, Rob; r-sig-ecology at r-project.org
Subject: RE: Appropriate mixed model?

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:19}}

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
-- 
This message (and any attachments) is for the recipient only. NERC
is subject to the Freedom of Information Act 2000 and the contents
of this email and any reply you make may be disclosed by NERC unless
it is exempt from release under the Act. Any material supplied to
NERC may be stored in an electronic records management system.

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 should not be read, copied or disclosed to anyone else outwith the University without the permission of the sender. It is your responsibility to ensure that this message and any attachments are scanned for viruses or other defects. 
Edinburgh Napier University does not accept liability for any loss or
damage which may result from this email or any attachment, or for errors or omissions arising after it was sent. Email is not a secure medium. Email entering the University's system is subject to routine monitoring and filtering by the University. 

Edinburgh Napier University is a registered Scottish
charity.
Registration number SC018373



More information about the R-sig-ecology mailing list