Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. ·...
Transcript of Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. ·...
![Page 1: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/1.jpg)
Generalized Linear Models
based on Zuur et al.
![Page 2: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/2.jpg)
Kuhnert and Venables
![Page 3: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/3.jpg)
Normal Distribu.on example: weights of 1280 sparrows
Sparrows<-‐read.table("/Users/dbm/Documents/W2025/ZuurDataMixedModelling/Sparrows.txt",header=TRUE) par(mfrow = c(2, 2)) hist(Sparrows$wt, nclass = 15, xlab = "Weight", main = "Observed data",xlim=c(10,30)) hist(Sparrows$wt, nclass = 15, xlab = "Weight", main = "Observed data", freq = FALSE,xlim=c(10,30)) Y <-‐ rnorm(1281, mean = mean(Sparrows$wt), sd = sd(Sparrows$wt)) hist(Y, nclass = 15, main = "Simulated data",xlab = "Weight",xlim=c(10,30)) X <-‐seq(from = 0,to = 30,length = 200) Y <-‐ dnorm(X, mean = mean(Sparrows$wt), sd = sd(Sparrows$wt)) plot(X, Y, type = "l", xlab = "Weight", ylab = "Probabli]es", ylim = c(0, 0.25), xlim = c(10, 30), main = "Normal density curve") par(mfrow = c(1, 1))
![Page 4: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/4.jpg)
Observed data
Weight
Frequency
10 15 20 25 30
050
150
250
Observed data
Weight
Density
10 15 20 25 30
0.00
0.10
0.20
Simulated data
Weight
Frequency
10 15 20 25 30
050
100150200250
10 15 20 25 30
0.00
0.10
0.20
Normal density curve
Weight
Probablities
![Page 5: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/5.jpg)
![Page 6: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/6.jpg)
Poisson Distribu.on
In prac]ce the variance is o`en bigger than the mean -‐> overdispersion
![Page 7: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/7.jpg)
![Page 8: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/8.jpg)
Gamma Distribu.on
![Page 9: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/9.jpg)
![Page 10: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/10.jpg)
Binomial Distribu.on
![Page 11: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/11.jpg)
![Page 12: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/12.jpg)
Natural Exponen.al Family
to get, e.g., Poisson:
![Page 13: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/13.jpg)
![Page 14: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/14.jpg)
Generalized Linear Models
![Page 15: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/15.jpg)
![Page 16: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/16.jpg)
![Page 17: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/17.jpg)
Generalized Linear Models: Poisson regression
![Page 18: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/18.jpg)
x <-‐ 0:100 y <-‐ rpois(101,exp(0.01+0.03*x)) MyData <-‐ data.frame(x,y) MyModel <-‐ glm(y~x,data=MyData,family=poisson) summary(MyModel) coefs <-‐ coef(MyModel) plot(y~x,MyData,ylim=c(0,26)) par(new=TRUE) plot(x,exp(0.01+0.03*x),ylim=c(0,26),type="l") par(new=TRUE) plot(x,exp(coefs[1]+coefs[2]*x),ylim=c(0,26),type="l",col="red")
Es]mates parameters by maximizing the likelihood:
L = µi × e−µi
yi!i∏ , µi = exp(β0 + β1x1 +…+ βd xd )
![Page 19: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/19.jpg)
![Page 20: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/20.jpg)
![Page 21: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/21.jpg)
RoadKills <-‐ read.table("/Users/dbm/Documents/W2025/ZuurDataMixedModelling/RoadKills.txt",header=TRUE) RK <-‐ RoadKills #Saves some space in the code plot(RK$D.PARK, RK$TOT.N, xlab = "Distance to park", ylab = "Road kills") M1 <-‐ glm(TOT.N ~ D.PARK, family=poisson, data=RK) summary(M1) M2 <-‐ glm(TOT.N ~ D.PARK, family=gaussian, data=RK) summary(M2)
![Page 22: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/22.jpg)
Call: glm(formula = TOT.N ~ D.PARK, family = poisson, data = RK) Deviance Residuals: Min 1Q Median 3Q Max -‐8.1100 -‐1.6950 -‐0.4708 1.4206 7.3337 Coefficients: Es]mate Std. Error z value Pr(>|z|) (Intercept) 4.316e+00 4.322e-‐02 99.87 <2e-‐16 *** D.PARK -‐1.059e-‐04 4.387e-‐06 -‐24.13 <2e-‐16 *** -‐-‐-‐ Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 1071.4 on 51 degrees of freedom Residual deviance: 390.9 on 50 degrees of freedom AIC: 634.29 Number of Fisher Scoring itera]ons: 4
![Page 23: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/23.jpg)
Residual Deviance: Difference in G2 = -‐2 log L between a maximal model where every observa]on has Poisson parameter equal to the observed value and your model Null Deviance: Difference in G2 = -‐2 log L between a maximal model where every observa]on has Poisson parameter equal to the observed value and the model with just an intercept Some]mes useful to compare residual deviances for two models. Differences are chi-‐square distributed with degrees of freedom equal to the change in the number of parameters
![Page 24: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/24.jpg)
![Page 25: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/25.jpg)
MyData <-‐ data.frame(D.PARK = seq(from = 0, to = 25000, by = 1000)) G <-‐ predict(M1, newdata = MyData, type = "link", se = TRUE) F <-‐ exp(G$fit) FSEUP <-‐ exp(G$fit + 1.96 * G$se.fit) FSELOW <-‐ exp(G$fit -‐ 1.96 * G$se.fit) lines(MyData$D.PARK, F, lty = 1) lines(MyData$D.PARK, FSEUP, lty = 2) lines(MyData$D.PARK, FSELOW, lty = 2)
![Page 26: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/26.jpg)
0 5000 10000 15000 20000 25000
020
4060
80100
Distance to park
Roa
d ki
lls
![Page 27: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/27.jpg)
Model Selec.on in Generalized Linear Models
![Page 28: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/28.jpg)
X
Y
235000
240000
245000
250000
255000
258500
library(AED) library(lawce) xyplot(Y ∼ X, aspect = "iso", col = 1, pch = 16, data = RoadKills)
![Page 29: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/29.jpg)
Histogram of RK$POLIC
RK$POLIC
Frequency
0 4 8
010
2030
40
Histogram of RK$WAT.RES
RK$WAT.RES
Frequency
0 2 4 6
010
2030
Histogram of RK$URBAN
RK$URBAN
Frequency
0 10 20 30
05
1015
2025
3035
Histogram of RK$OLIVE
RK$OLIVE
Frequency
0 20 40 60
05
1015
2025
30
Histogram of RK$L.P.ROAD
RK$L.P.ROAD
Frequency
0.5 1.5 2.5
05
1015
2025
Histogram of RK$SHRUB
RK$SHRUB
Frequency
0.0 0.5 1.0 1.5
05
1015
Histogram of RK$D.WAT.COUR
RK$D.WAT.COUR
Frequency
0 400 800
02
46
810
![Page 30: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/30.jpg)
![Page 31: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/31.jpg)
![Page 32: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/32.jpg)
How to select variables for inclusion in the model
• Hypothesis tes]ng • Use the z-‐sta]s]c produced by summary • drop1(M2,test=“Chi”) • anova(M2,M3,test=“Chi”)
• AIC, BIC, etc. -‐ use step(M2) etc.
![Page 33: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/33.jpg)
![Page 34: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/34.jpg)
![Page 35: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/35.jpg)
![Page 36: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/36.jpg)
Overdispersion
Recall that in the Poisson model we assume the mean = variance
With no overdispersion, residual mean deviance should be close to 1: 270.23 / 42 = 6.43…not close to 1
Or, consider mean squared residuals:
sum(resid(M2, type=“pearson”)^2) / 42 = 5.93 (suggests standard errors should be increased by sqrt(5.93) = 2.44) Quasi-‐Poisson model accounts for overdispersion:
![Page 37: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/37.jpg)
![Page 38: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/38.jpg)
Overdispersion
AIC not defined for quasi-‐Poisson model Use drop1(M4, test=“F”) is approximately correct or, be~er, do cross-‐valida]on
![Page 39: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/39.jpg)
0 5000 10000 15000 20000 25000
020
4060
80100
Distance to park
Road
kills
![Page 40: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/40.jpg)
Residuals for Poisson Model
Because variance increases with the mean, standard residual doesn’t make much sense. Can use “Pearson residuals”
For quasi-‐Poisson should also divide by the square root of the overdispersion parameter
![Page 41: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/41.jpg)
Nega.ve Binomial GLM
![Page 42: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/42.jpg)
![Page 43: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/43.jpg)
![Page 44: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/44.jpg)
![Page 45: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/45.jpg)
M7 <-‐ glm.nb(formula = TOT.N ~ OPEN.L + L.WAT.C + SQ.LPROAD + D.PARK, data = RK) plot(M7)
![Page 46: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/46.jpg)
1.5 2.0 2.5 3.0 3.5 4.0 4.5
-3-2
-10
12
Predicted values
Residuals
Residuals vs Fitted
2
1
39
-2 -1 0 1 2
-3-2
-10
12
Theoretical Quantiles
Std
. dev
ianc
e re
sid.
Normal Q-Q
2
1
37
1.5 2.0 2.5 3.0 3.5 4.0 4.5
0.0
0.5
1.0
1.5
Predicted values
Std. deviance resid.
Scale-Location21
37
0.00 0.05 0.10 0.15 0.20 0.25
-2-1
01
2
Leverage
Std
. Pea
rson
resi
d.
Cook's distance
0.5Residuals vs Leverage
19
12
![Page 47: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/47.jpg)
1.5 2.0 2.5 3.0 3.5 4.0 4.5
-8-6
-4-2
02
4
Predicted values
Residuals
Residuals vs Fitted
2
137
-2 -1 0 1 2
-3-2
-10
12
3
Theoretical Quantiles
Std
. dev
ianc
e re
sid.
Normal Q-Q
2
1
8
1.5 2.0 2.5 3.0 3.5 4.0 4.5
0.0
0.5
1.0
1.5
Predicted values
Std. deviance resid.
Scale-Location2
18
0.0 0.1 0.2 0.3 0.4 0.5 0.6
-3-2
-10
12
3
Leverage
Std
. Pea
rson
resi
d.
Cook's distance
1
0.5
0.5
1
Residuals vs Leverage
8
12
Contrast with quasi-‐Poisson model M4
![Page 48: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/48.jpg)
What if zero is impossible?
![Page 49: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/49.jpg)
![Page 50: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/50.jpg)
Library(VGAM) data(Snakes) M3A <-‐ vglm(N_days~PDayRain + Tot_Rain + Road_Loc + PDayRain:Tot_Rain, family = posnegbinomial, data = Snakes) M4A <-‐ vglm(N_days~PDayRain + Tot_Rain + Road_Loc + PDayRain:Tot_Rain, family = pospoisson, data = Snakes)
![Page 51: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/51.jpg)
Too many zeroes much more common
try plot(table(rpois(10000,lambda)))
![Page 52: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/52.jpg)
![Page 53: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/53.jpg)
Zero-‐altered Models
![Page 54: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/54.jpg)
Zero-‐altered Models
Get the es.mates of γ and β via maximum likelihood es.ma.on
library(pscl) f1 <-‐ formula(Intensity~fArea*fYear + Length | fArea * fYear + Length) H1A <-‐ hurdle(f1, dist = "poisson", link = "logit", data = ParasiteCod2) H1B <-‐ hurdle(f1, dist = "negbin", link = "logit", data = ParasiteCod2) AIC(H1A,H1B)
logis]c part count part
Can s]ll have overdispersion in ZIP/ZAP models so check ZINB/ZANB
![Page 55: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/55.jpg)
Zero-‐inflated Models
![Page 56: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/56.jpg)
![Page 57: Generalized*Linear*Models* - Columbia Universitymadigan/W2025/notes/GLM.pdf · 2013. 2. 25. · Observed data Weight cy n e u q re F 10 15 20 25 30 0 50 150 250 Observed data Weight](https://reader036.fdocuments.in/reader036/viewer/2022071415/611122a8cf63cb5c86580914/html5/thumbnails/57.jpg)