Crash course on GLMs Richard Erickson Quantitative Ecologist - - PowerPoint PPT Presentation

crash course on glms
SMART_READER_LITE
LIVE PREVIEW

Crash course on GLMs Richard Erickson Quantitative Ecologist - - PowerPoint PPT Presentation

DataCamp Hierarchical and Mixed Effects Models in R HIERARCHICAL AND MIXED EFFECTS MODELS IN R Crash course on GLMs Richard Erickson Quantitative Ecologist DataCamp Hierarchical and Mixed Effects Models in R Assumption of normality Residuals


slide-1
SLIDE 1

DataCamp Hierarchical and Mixed Effects Models in R

Crash course on GLMs

HIERARCHICAL AND MIXED EFFECTS MODELS IN R

Richard Erickson

Quantitative Ecologist

slide-2
SLIDE 2

DataCamp Hierarchical and Mixed Effects Models in R

Assumption of normality

Residuals are "normal" Transformation "The arcsine is asinine:..." Alternative distributions

slide-3
SLIDE 3

DataCamp Hierarchical and Mixed Effects Models in R

R syntax for GLM

glm(y ~ x, family = "gaussian") ?family

slide-4
SLIDE 4

DataCamp Hierarchical and Mixed Effects Models in R

slide-5
SLIDE 5

DataCamp Hierarchical and Mixed Effects Models in R

Example with Poisson regression

glm( y ~ x, family = "poisson")

slide-6
SLIDE 6

DataCamp Hierarchical and Mixed Effects Models in R

slide-7
SLIDE 7

DataCamp Hierarchical and Mixed Effects Models in R

Example with logistic regression

# binary: y = 0 or 1 glm( y ~ x, family = "binomial") # Wilkinson-Rogers: cbind(success, failure) glm( cbind(success, failure) ~ x, family = "binomial") # Weighted format: y = 0.3, weights = 10 glm( y ~ x, weights = weights, family = "binomial")

slide-8
SLIDE 8

DataCamp Hierarchical and Mixed Effects Models in R

Let's practice!

HIERARCHICAL AND MIXED EFFECTS MODELS IN R

slide-9
SLIDE 9

DataCamp Hierarchical and Mixed Effects Models in R

Binomial data

HIERARCHICAL AND MIXED EFFECTS MODELS IN R

Richard Erickson

Quantitative Ecologist

slide-10
SLIDE 10

DataCamp Hierarchical and Mixed Effects Models in R

Examples of binomial data

Coin/toss Yes/No Dead/alive Behavior Choice Study result

slide-11
SLIDE 11

DataCamp Hierarchical and Mixed Effects Models in R

Binomial data with glmer

glmer( y ~ x + (1/ group), family = 'error term')

slide-12
SLIDE 12

DataCamp Hierarchical and Mixed Effects Models in R

Dose-response case study

Study had increasing dose Repeated in triplicate Requires glmer(), not glm()

slide-13
SLIDE 13

DataCamp Hierarchical and Mixed Effects Models in R

Internet purchase

"Purchases" or "Pass" "ranking" of product 0 to 20 "friend recommendation" Tracked sales with 4 focal groups in different "cities" Do friend recommendations help?

slide-14
SLIDE 14

DataCamp Hierarchical and Mixed Effects Models in R

Odds-ratio

Regression coefficients hard to explain Odds-ratios sometimes easier If Group A has odds-ratio of 2.0 ×, 2:1 A will do something compared to the other group Extract by exponentiation logistic coefficients

exp(coef(modelOut))

slide-15
SLIDE 15

DataCamp Hierarchical and Mixed Effects Models in R

Let's practice!

HIERARCHICAL AND MIXED EFFECTS MODELS IN R

slide-16
SLIDE 16

DataCamp Hierarchical and Mixed Effects Models in R

Count data

HIERARCHICAL AND MIXED EFFECTS MODELS IN R

Richard Erickson

Quantitative Ecologist

slide-17
SLIDE 17

DataCamp Hierarchical and Mixed Effects Models in R

Examples of count data

Events at a rate of time Events per area Differs from binomial because no explicit upper limit

slide-18
SLIDE 18

DataCamp Hierarchical and Mixed Effects Models in R

Alternative to Chi-square test

Chi-square test used to compare binned counts Poisson glm can be an alternative

slide-19
SLIDE 19

DataCamp Hierarchical and Mixed Effects Models in R

R Syntax for Poisson regression with glmer

glm(y ~ x, family = 'poisson') glmer(y ~ x + (1|group), family = 'poisson')

slide-20
SLIDE 20

DataCamp Hierarchical and Mixed Effects Models in R

Marketing click through case study

Redesigned website Clicks on different webpages Focus groups looked at old and new Marketer was using a linear mixed model Demonstrate how a generalized model

slide-21
SLIDE 21

DataCamp Hierarchical and Mixed Effects Models in R

Chlamydia by age-group and county data

By county and age group Important for public health Public policy application Marketing/drug research State of IL

slide-22
SLIDE 22

DataCamp Hierarchical and Mixed Effects Models in R

Let's apply Poisson regression!

HIERARCHICAL AND MIXED EFFECTS MODELS IN R