Upgrade to Pro — share decks privately, control downloads, hide ads and more …

6003: Week 9 - GLMMs

6003: Week 9 - GLMMs

GLMM lecture

MI Fisheries Science

March 09, 2018
Tweet

More Decks by MI Fisheries Science

Other Decks in Science

Transcript

  1. Chapter 9: Generalized Linear Mixed Effects Models CatchRate ~ Poisson

    (μ ij ) E(CatchRate) = μ ij Log(μ ij ) = GearType ij + Temperature ij + FleetDeployment i FleetDeployment i ~ N(0, σ2) Using lme4: m <- glmer(CatchRate ~ GearType + Temperature + (1 | FleetDeployment), family = poisson) FISH 6003 FISH 6003: Statistics and Study Design for Fisheries Brett Favaro 2017 This work is licensed under a Creative Commons Attribution 4.0 International License
  2. Land Acknowledgment We would like to respectfully acknowledge the territory

    in which we gather as the ancestral homelands of the Beothuk, and the island of Newfoundland as the ancestral homelands of the Mi’kmaq and Beothuk. We would also like to recognize the Inuit of Nunatsiavut and NunatuKavut and the Innu of Nitassinan, and their ancestors, as the original people of Labrador. We strive for respectful partnerships with all the peoples of this province as we search for collective healing and true reconciliation and honour this beautiful land together. http://www.mun.ca/aboriginal_affairs/
  3. This week: • The logic of GLMMs • A brief

    review of GLMM packages • A detailed execution of a GLMM
  4. Random Effect • Essentially a “grouping variable” • A categorical

    variable that imparts some sort of nesting structure into your data • Transects • “Strings” or “Fleets” of fishing gear • Individual identity (if you’re taking multiple observations from individuals) • A variable where either: • You don’t care about it, but need to include it to address dependency • You care about measuring the variance within different levels of the random effect • Not repeatable (i.e. “Tank 4” has no inherent, repeatable value) Fixed Effect • A variable with predetermined levels (or ranges) that is of direct interest. • All covariates we have used so far in the course have been fixed effects • E.g. • Age • Sex • Food treatment • Repeatable. (Male in this study meets an agreed-upon definition of male. Age 12 always means Age 12) Recall:
  5. Fish Size Month 1. As month increases, how much does

    Fish Size increase? 2. As we add food, how much does this relationship adjust upward? Low food → Medium food 3. Allow the regression line to adjust up or down for each tank (some tanks are better than others) 4. Allow the line to adjust up or down for each individual fish (some fish are better at growing than others) This model basically says there will be one regression line for every single fish. All have the same slope, but are adjusted up or down (i.e. their intercept shifts based on treatment (fixed), tank (random), and fish ID (random) Fixed part: Random part:
  6. • Random intercept model • Plots may look like this:

    • Thick line is “for a typical group” • Thin lines are regression lines for each specific group Zuur et al. 2010 • Random intercept, random slope model
  7. Sizeij ~ N(μij , σ2) E(Sizeij ) = μij Var(Sizeij

    ) = σ2 Sizeij = β0 + FoodTreatmentij + ai ai ~ N(0, σ2 Tank ) Surprise! You have already done a GLMM! A GLMM is just a mixed effects model that meets the above specification Gaussian distribution Identity link Predictor function Specification of fixed and random components
  8. Y data Distribution Fixed only Fixed + Random Continuous Gaussian

    lm() It’s a little more complicated... Count Poisson glm(family = Poisson) Count – overdispersed Negative-binomial glm.nb() 0’s and 1’s (single observations that did or did not occur) Bernoulli glm(family = binomial) Proportion Binomial glm(Y = cbind(Success, Failure), family = binomial) Rate Beta betareg() Unordered categories Multinomial multinom() Ordered categories Cumulative logistical regression clm()
  9. http://glmm.wikidot.com/pkg-comparison • A wide variety of R packages exist for

    running GLMMs • See the website above for detailed summary
  10. Warning • I am going to dramatically oversimplify GLMMs in

    this lecture • The underlying mathematics are complicated: • See previous slide: Parameter estimation differs across packages • Inference (i.e. “Is this a statistically significant effect?”) can be constructed many ways, and packages use different approaches • For small datasets, GLMMs may not work at all • When designing your study, minimize complexity to streamline analysis. While you CAN usually fit complex models, more can go wrong. I have posted links to some good self-study resources on the course website.
  11. All the rules of GLM’s still apply to GLMM’s Same

    exploration Same validation, which depends on distribution - e.g. Poisson = check for overdispersion - e.g. Gaussian = check for homogeneity of variance, and approx. normality - Check residuals vs. fitted values - And check for patterns of residuals vs. covariates in and out of the model Same model selection - But you may also want to compare models with different random effects structures - Can use AIC to do this. But try to define your random effects structure a priori
  12. @nicci_zarg Nicci Zargarpour Mary Alliston Butt @Jon_Bergs Jonathan Bergshoeff Can

    better trap designs improve catch rates of green crab? Does it matter which bait we use to catch green crab? Which is best? Do green crabs reduce lobster catch by messing with the traps?
  13. Does it matter which bait we use to catch green

    crab? Which is best? Today’s dataset: Desirable to maximize CPUE of green crab. While we have no idea how many green crabs can exist in an ecosystem before they cause damage, we believe removing them helps mitigate the damage they cause. • Field data collected in summer 2016 • Green crabs were caught using standard Fukui traps • CPUE with four bait types compared: • Herring (default), mussels, squid, cod • Key Questions: • Which catches most? • Which catches biggest?
  14. Zuur and Ieno 2016 Fox Harbour North Harbour Block C

    Block D Block A Block B Slots 1-4
  15. Zuur and Ieno 2016 Body Size: Observations also nested within

    TrapID Location Block FH/NH A B C D Slot 1,2,3,4 … Replicates Herring Mussel Cod Squid - Each slot should experience each bait - Note: Need >5 levels for random effect (We will lump Block/Slot together, creating 16 values)