(Generalized) Mixed-Effects Models – (G)MEMs
description
Transcript of (Generalized) Mixed-Effects Models – (G)MEMs
![Page 1: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/1.jpg)
(Generalized) Mixed-Effects Models – (G)MEMs
Yann Hautier, NutNet meeting 16th Aug 2011
![Page 2: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/2.jpg)
Maximum Entropy Models (Grace 2011)
MEM
![Page 3: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/3.jpg)
Maximum Entropy Models (Grace 2011)Muddled Eric Models (Seabloom 2011)
MEM
![Page 4: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/4.jpg)
Maximum Entropy Models (Grace 2011)Muddled Eric Models (Seabloom 2011)Mixed-Effects Models (Fischer 1918)
MEM
![Page 5: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/5.jpg)
Books
![Page 6: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/6.jpg)
LM – Classical least-square
0 2 4 6 8
24
68
1012
Data
tannin
grow
th
0 2 4 6 8
24
68
1012
SST
tannin
grow
th
0 2 4 6 8
24
68
1012
SSE
tannin
grow
th
0 2 4 6 8
24
68
1012
SSR
tannin
grow
th
![Page 7: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/7.jpg)
MEM – Maximum Mikelihood
0.1 0.2 0.3 0.4 0.5 0.6
12
34
5
lambda
log
-Lik
elih
oo
d 95%0 2 4 6 8
24
68
1012
Data
tannin
grow
th
0 2 4 6 82
46
810
12
SST
tannin
grow
th
0 2 4 6 8
24
68
1012
SSE
tannin
grow
th
0 2 4 6 8
24
68
1012
SSR
tannin
grow
th
Given a set of dataand a chosen model which parameters of the model produce the best model fit and make the data most likely to be observed
![Page 8: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/8.jpg)
Fixed and Random EffectsFixed effects:• Experimentally manipulated factors• Influence only the mean of a response• BLUEs (Best Linear Unbiased Estimates)• Unknown constants to be estimated from data• Limited to the range of the fixed effect examined
Random effects• Blocks, Plots, Sites, etc.; random subset of larger
population• Influence the variance/covariance structure• BLUPs (Best Linear Unbiased Predictions)• ‘Prediction’ of the population of random effects
![Page 9: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/9.jpg)
Fixed and Random EffectsFixed effects:• Experimentally manipulated factors• Influence only the mean of a response• BLUEs (Best Linear Unbiased Estimates)• Unknown constants to be estimated from data• Limited to the range of the fixed effect examined
Random effects• Blocks, Plots, Sites, etc.; random subset of larger
population• Influence the variance/covariance structure• BLUPs (Best Linear Unbiased Predictions)• ‘Prediction’ of the population of random effects
Not inequivocal – grey area in between
![Page 10: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/10.jpg)
Why use mixed-effects models?
• To properly account for covariance structure in grouped data
• To treat fixed and random effects appropriately
• Fixed effects: Estimate and test
• Random effects: Predict and test
![Page 11: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/11.jpg)
Why use Modern Mixed-effects Models (in particular)?
• Modern methods (ML, REML etc.) can give unbiased predictions of variance components for unbalanced data
• More efficient use of degrees of freedom than traditional approach because fixed x random interactions are random terms and only require 1 DF to estimate VC
• Estimating variance components by ML-based method avoids the mixed-model debate over correct error term since the VCs are estimated directly by REML etc.
• To get shrinkage estimates and reduce risk of over-fitting• To properly account for covariance structure in grouped
data
![Page 12: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/12.jpg)
Generalized Linear Mixed Models (GLMMs)
• Combine the properties of two statistical frameworks
• Linear mixed models (incorporation random effects)
• Generalized linear models (handling non normal data by using link functions and exponential family)
![Page 13: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/13.jpg)
lmer(X ~ Y + (1 + logS | site) + (1| Block ) + (1| mix), family = " ", data)
lme(X ~ Y, random = list(Site = ~1 + sr.log2, Block = ~1, mix = ~1), data)
lm, lme, lmer syntax
Family:binomial(link = "logit")gaussian(link = "identity") Gamma(link = "inverse") inverse.gaussian(link = "1/mu^2") poisson(link = "log") quasi(link = "identity", variance = "constant") quasibinomial(link = "logit") quasipoisson(link = "log")
lm(X ~ Y, data)
![Page 14: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/14.jpg)
ls1Machine <- lme( score ~ Machine, data = Machines)
Example – MachinesBalanced vs. Unbalanced data
delete selected rows from the Machines dataMachinesUnbal <- Machines[ -c(2,3,6,8,9,12,19,20,27,33), ]
ls2Machine <- lme( score ~ Machine, data = MachinesUnbal)
(Intercept) MachineB MachineC 52.355556 7.966667 13.916667
(Intercept) MachineB MachineC 52.32102 8.00837 13.95120
![Page 15: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/15.jpg)
fm1Machine <- lme( score ~ Machine, data = Machines, random = ~ 1 | Worker / Machine)
Example – MachinesBalanced vs. Unbalanced data
(Intercept) MachineB MachineC 52.355556 7.966667 13.916667
delete selected rows from the Machines dataMachinesUnbal <- Machines[ -c(2,3,6,8,9,12,19,20,27,33), ]
fm2Machine <- lme( score ~ Machine, data = MachinesUnbal , random = ~ 1 | Worker / Machine)
(Intercept) MachineB MachineC 52.354000 7.962446 13.918222
![Page 16: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/16.jpg)
Example – BIODEPTH Manipulation of diversity:
Species richness
Species composition
Hector et al. 1999, Science
![Page 17: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/17.jpg)
ls1 <- lm(terms(ANPP~ Site+Block+SR.log2+Site:SR.log2+Mix+Site:Mix, keep.order= TRUE), data= Biodepth)
Example – BIODEPTHDegrees of freedom
Df Sum Sq Mean Sq F value Pr(>F) Site 7 14287153 2041022 126.5168 < 2.2e-16 ***Block 7 273541 39077 2.4223 0.02072 * SR.log2 1 5033290 5033290 311.9986 < 2.2e-16 ***Site:SR.log2 7 1118255 159751 9.9025 9.316e-11 ***Mix 189 17096361 90457 5.6072 < 2.2e-16 ***Site:Mix 28 1665935 59498 3.6881 2.252e-08 ***Residuals 224 3613660 16132
mem1 <- lmer(ANPP~ SR.log2 +(1|Site)+(1|Block)+(1|Mix)+(1|Site:Mix), data= Biodepth)
Df Sum Sq Mean Sq F valueSR.log2 1 772347 772347 47.544
![Page 18: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/18.jpg)
ls1 <- lm(terms(ANPP~ Site+Block+SR.log2+Site:SR.log2+Mix+Site:Mix, keep.order= TRUE), data= Biodepth)
Example – BIODEPTHDegrees of freedom
Df Sum Sq Mean Sq F value Pr(>F) Site 7 14287153 2041022 126.5168 < 2.2e-16 ***Block 7 273541 39077 2.4223 0.02072 * SR.log2 1 5033290 5033290 311.9986 < 2.2e-16 ***Site:SR.log2 7 1118255 159751 9.9025 9.316e-11 ***Mix 189 17096361 90457 5.6072 < 2.2e-16 ***Site:Mix 28 1665935 59498 3.6881 2.252e-08 ***Residuals 224 3613660 16132
mem1 <- lmer(ANPP~ SR.log2 +(1|Site)+(1|Block)+(1|Mix), data= Biodepth) mem2 <- lmer(ANPP~ SR.log2 +(1|Site)+(1|Block), data= Biodepth)
Df AIC BIC logLik Chisq Chi Df Pr(>Chisq) mem2 5 6394.7 6415.4 -3192.4 mem1 6 6277.3 6302.1 -3132.6 119.41 1 < 2.2e-16 ***
Uses only 6 DF instead of 7+7+1+7+189+28=239!!!
![Page 19: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/19.jpg)
Example – BIODEPTHError terms
Spehn et al. 2005
![Page 20: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/20.jpg)
Example – BIODEPTHError terms
Spehn et al. 2005
![Page 21: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/21.jpg)
The Great Mixed Model Muddle
F tests for fixed-effects, random-effects and mixed-effects models
Source A and B fixed A and B randomA fixed, B randomRestricted version
A fixed, B randomUnrestricted version
A MSA
MSResidual
MSA
MSAB
MSA
MSAB
MSA
MSAB
B MSB
MSResidual
MSB
MSAB
MSB
MSResidual
MSB
MSAB
AB MSAB
MSResidual
MSAB
MSResidual
MSAB
MSResidual
MSAB
MSResidual
![Page 22: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/22.jpg)
Example – BIODEPTHError terms
mem4 <- lme (ANPP~ SR.log2+Block, random=list(Site = ~1, Mix = ~1), data= Biodepth, na.action=na.omit)
numDF denDF F-value p-value(Intercept) 1 413 1781.8981 <.0001SR.log2 1 413 94.3233 <.0001Site 7 7 33.4856 1e-04
mem3 <- lme (ANPP~ SR.log2+Site, random=list(Block = ~1, Mix = ~1), data= Biodepth, na.action=na.omit)
numDF denDF F-value p-value(Intercept) 1 224 457.6593 <.0001SR.log2 1 224 57.2133 <.0001Block 7 217 6.0297 <.0001
Crossed-random effects – to be considered with care. Not handled by lme, lmer would do the job, but no P-values!!!
![Page 23: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/23.jpg)
Crossed random effects
Block
Species compossition
![Page 24: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/24.jpg)
ShrinkageNo pooling (lmList(ANPP~ SR.log2|Site, data= Biodepth))
![Page 25: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/25.jpg)
ShrinkageNo pooling (lmList(ANPP~ SR.log2|Site, data= Biodepth))
Complete pooling (lm(ANPP~ SR.log2, data= Biodepth))
![Page 26: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/26.jpg)
ShrinkageNo pooling (lmList(ANPP~ SR.log2|Site, data= Biodepth))
Complete pooling (lm(ANPP~ SR.log2, data= Biodepth))
Mixed-effects models (lmer(ANPP~ SR.log2 +(SR.log2|Site)+(1|Block)+(1|Mix)+(1|Site:Mix), data= Biodepth))
![Page 27: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/27.jpg)
![Page 28: (Generalized) Mixed-Effects Models – (G)MEMs](https://reader035.fdocuments.net/reader035/viewer/2022081505/568158e4550346895dc62735/html5/thumbnails/28.jpg)
Mixed-effects model analysis: Overview
• Estimate and test the fixed effects just as in fixed-effects analysis but it makes no sense to estimate and test the random effects.
• Instead the random effects are treated as in variance components analysis: we predict and test the variance components (often expressed in standard deviation form so that they are back on the original scale of the response).
• The covariances (or correlations) between random effects can also be estimated – between repeated measurement locations or times for example
• Fixed effects and random effects are tested differently.