Mixed Effects Models Rebecca Atkins and Rachel Smith March 30, 2015

Click here to load reader

download Mixed Effects Models Rebecca Atkins and Rachel Smith March 30, 2015

of 24

  • date post

  • Category


  • view

  • download


Embed Size (px)

Transcript of Mixed Effects Models Rebecca Atkins and Rachel Smith March 30, 2015

  • Mixed Effects ModelsRebecca Atkins and Rachel SmithMarch 30, 2015

  • Up to nowGeneral Linear Model (lm)yi = + 11 + ... + + with ~ N(0, i2)Generalized Linear Model (glm)Non-normal error distributions for response variable; link functionGeneralized Additive Model (gam)Identify smoothed lines of best fit for non-linear relationshipsGeneralized Least Squares (gls)Altered variance structures of Normal distribution

  • Residuals are normally distributedHistogram or Q-Q plot Residuals are homogenous or homoscedastic (constant variance) No autocorrelation between observations plot residuals No colinearity between independent variablesPairs plot in R The model is not biased by unduly influential observations Cooks Distance and leverage Independent observations

  • Nested data?Blocking?Repeated measures? Split-plot designs? Spatial or temporal autocorrelation? But what about

  • Use of mixed modelsMixed effects models or multilevel models and are used when the data have a hierarchical formwhich can have both fixed and random coefficients together with multiple error terms.1Zuur et al. 2007. Analyzing Ecological Data. Pg 127

  • Rob Thomas

  • Rob Thomas

  • Model Structure

    Rachel S Smith - Just "Model Structure"

  • Parameter estimationML = Maximum LikelihoodCommon with GLMREML = Restricted Maximum LikelihoodCorrects ML estimation for the number of fixed covariatesLess influenced by outliers than ML estimatesCommon with LMM

  • R packageslibrary(nlme) = Non-Linear Mixed Effectslme = Linear Mixed Effects gls = Generalised Least Squaresmodel
  • Nested Design ExampleAre there any differences between the NAP-richness relationship at these 9 beaches?NAP = tidal height, predictive variableSpecies richness = response variableFrom Zuur 2009

  • Mixed Effects Model StructureFrom Zuur 2009

    Rachel S Smith - Is this the right way to say this?Rachel S Smith - How does slope/intercept relate to this model?

  • Model 1: Constant slope/interceptyi = + i + with ~ N(0, i2) Assumes that the richness-NAP relationship is the same at all beachesmodel1
  • Model 2: varying intercept, same slopeyij = + ij + aj + j where aj ~ N(0, a2) and j ~ N(0, 2)model2
  • Model 3: varying slope, varying interceptyij = + ij + aj + bjxij + j where aj ~ N(0, a2), bj ~ N(0, b2), and j ~ N(0, 2)model3
  • Additional complexityGeneralized Mixed models: lmer() and mgcv()GLMM and GAMM; different underlying error distributions

    Rachel S Smith - Do we have questions for Dr.Drake? What do we say when he asks "what else we want the class to take away"?Rachel S Smith

  • Mixed Effects ResourcesMixed Effects Models and Extensions in Ecology with R (2009). Zuur, Ieno, Walker, Saveliev and Smith. Springer

  • Model selection?Check assumptions of the model (e.g., residuals and colinearity)Compare competing models (R. Thomas recommends comparing a gls (containing no random effects) to a linear effects mixed model to assess the importance of the random effect). Compare nested models using AIC OR: stepwise model refinement

  • The End!

  • Presenting examples (how many?)How many types of models (nested- repeated measures, split-plot designs, nonlinear, linear) Page 102 (online) and 71 (book) of Zuur BDRipley 271 (pdf)Random slope vs intercept models Relate to R code / packages? LME4 and NLME

  • General/Generalised linear model General/Generalised additive model (GAM): identify smoothed lines of best fit through a dataset. A non-parametric smoothed relationship is chosen to fit a curve. Non-Gaussian error distributions can also be chosen as with GLMGeneralised least squares (GLS): incorporates a random term that takes into account heteroskedasticity (non-homogenous variance and/or autocorrelation structures)Can use gls function in nlme package Multiple variance structures to pick from

  • General/Generalised linear mixed modeling nlme; lme4; asreml Model fitting ML (Maximum likelihood): common with GLM REML (Restricted Maximum likelihood): corrects ML estimation for the number of fixed covariates. Less influenced by outliers than ML estimates Structure Random intercept (same autocorrelation function for all levels of fixed factors) Random intercept + slope (autocorrelation function varies across different levels of the fixed factor) Random slope and > 1 random effect Random effect only aside from the intercept (useful as a null model to evaluate the importance of fixed effects in a GLMM) Fixed factors only (not really a mixed model, but useful as a null model to evaluate the importance of random effects in a GLMM)

    Generalised additive mixed modeling

  • Model 5: Random effect, no fixed effectyi= + bi+ j with j ~ N(0, 2)model5