1. The document discusses using generalized linear mixed models (GLMMs) to analyze parasite egg count (EPG) data from Asian elephant fecal samples. GLMMs were used to account for repeated measures from the same elephants and non-normal data distribution.
2. Models were built to analyze EPG both within individual elephants (different samples from the same bolus) and between boluses within elephants. Fixed effects included sample type and location, elephant age and sex, and camp. Elephant ID was included as a random effect.
3. Tips were provided for GLMM modeling in R, including using certain optimizers, testing different models with anova(), and keeping data and outputs well organized.
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Sheffield R Jan 2015 - Using R to investigate parasite infections in Asian elephants, Carly Lynsdale
1. A beginner’s view on
mixed modelling
#crapstats
carly.lynsdale@sheffield.ac.uk
CarlyLynsdale
MyanmarElephant
Using R to investigate parasite
infection in Asian Elephants
11. Why Generalised Linear Mixed Effects Models
(GLMMs)?
The effect of sample location (independent) on EPG
(dependent), with non-parametric data and accounting
for the effect of elephant age, sex and camp.
12. GLMMs deal with potential pseudoreplication by
including (fixed and) random measures.
The effect of sample location (independent) on EPG
(dependent), with non-parametric data and accounting
for the effect of elephant age, sex and camp.
Why Generalised Linear Mixed Effects Models
(GLMMs)?
13. GLMMs deal with potential pseudoreplication by
including (fixed and) random measures.
i.e. They account for repeated measures.
The effect of sample location (independent) on EPG
(dependent), with non-parametric data and accounting
for the effect of elephant age, sex and camp.
Why Generalised Linear Mixed Effects Models
(GLMMs)?
14. library(lme4) = Linear Mixed Effects v4
library(lme4) # Linear Mixed Effects v4
model1 <- glmer(y ~ xf + (1|xr),
family = poisson (link = “log”),
data = dframe1)
Package for GLMMs in R
15. library(MCMCglmm)= Bayesian Markov chain
Monte Carlo
library(asreml) = ASREML-R
ASREML-R is available on request for research/teaching, for
users with an academic email address. Register online at:
http://www.vsni.co.uk/software/free-to-use/teaching/asreml-teaching/registratio
Others…
library(nlme) = Non-Linear Mixed Effects
16. So what does my code look like?...
Within:
Between:
modelwithin<- glmer.nb (sqrt(epg) ~ sample1 + ageclass + camp + (1|id),
control=glmerControl(optimizer = "bobyqa"), data = within)
modelbetween <- glmer.nb (sqrt(epg) ~ bolusno1 + sample + ageclass + sex +
mothcol + (1|id1), data = bween, control = glmerControl
(optCtrl=list(optimizer="bobyqa")))
17. So what does my code look like?...
Within:
Between:
modelwithin<- glmer.nb (sqrt(epg) ~ sample1 + ageclass + camp + (1|id),
control=glmerControl(optimizer = "bobyqa"), data = within)
modelbetween <- glmer.nb (sqrt(epg) ~ bolusno1 + sample + ageclass + sex +
mothcol + (1|id1), data = bween, control = glmerControl
(optCtrl=list(optimizer="bobyqa")))
26. modelwithin <- glmer.nb(sqrt(epg) ~ sample1 + ageclass + sex +
camp + (1|id), control=glmerControl(optimizer = "bobyqa"), data =
within)
anova(modelwithin, modelwithin2)
Within (Centre v Edge)
modelwithin2 <- glmer.nb(sqrt(epg) ~ ageclass + sex + camp + (1|id),
control=glmerControl(optimizer = "bobyqa"), data = within)
27. Between (1st Bolus v 3rd Bolus
v Last Bolus)
modelbween <- glmer.nb(sqrt(epg) ~
bolusno1+sample+ageclass+sex+camp+(1|id1), data = bween,
control=glmerControl(optCtrl=list(optimizer="bobyqa")))
modelbween2 <- glmer.nb(sqrt(epg) ~
sample+ageclass+sex+camp+(1|id1), data = bween,
control=glmerControl(optCtrl=list(optimizer="bobyqa")))
28. My Final Tips……
• Sniff out free courses – NERC funded students / Sheffield
APS R course…
• Keep your data simple!
• Triple check everything (on different days), at least in the
beginning…
• Use word / excel / ppt to keep a summary of your
outputs / graphs for when you write up.
• Start naming models, exports, files properly from the
start.
29. Web Links
• http://www.r-bloggers.com/ - blog site
• Facebook R-space group
• http://www.nerc.ac.uk/skills/postgrad/currentstude
nts/latestopportunities/ - nerc free courses
• https://www.coursera.org/ - free online courses
• http://cran.r-project.org/doc/manuals/r-release/R-
intro.html - R’s own help site
• http://www.statmethods.net/interface/help.html -
nice stats
• https://github.com/ - online stats forum