A preliminary exploration into the Binomial Logistic Regression Models in R and their potential application Andrew Trant PPS Arctic - Labrador Highlands Research Group
One presentation in two parts Part 1 (today) -comparing binomial logistical regressions in R and Minitab -binomial GLMs and Odds Ratios Part 2 (next time) -using GLMs in conservation biology -an exploration of the past
Start off small….. before …and after Kettlewell, H B D (1956)
Research Question: Are the odds of survival higher for dark form (Melanic) than the light form (Typical)? Odds = e ( o) + e ( Type) + error (link = logit)
In Minitab: In R…
glm(formula = Nrecap/Nrel ~ type, family = binomial, data = moth,weights = Nrel) Call: Coefficients: (Intercept) typeTyp Degrees of Freedom: 1 Total (i.e. Null); 0 Residual Null Deviance: Residual Deviance: 1.592e-13 AIC: > summary(moth) Deviance Residuals: [1] 0 0 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) e-14 *** typeTyp e-06 *** --- Signif. codes: 0 ‘***’ ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: e+01 on 1 degrees of freedom Residual deviance: e-13 on 0 degrees of freedom AIC: Number of Fisher Scoring iterations: 3
In Minitab: In R… Signif. codes: 0 ‘***’ ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Odds = e ( o) + e ( Type) + error BUT R assumes that o = melanistic NOT typical > exp( ) = R: MINITAB: >exp( ) =
Odds = e ( o) + e ( Type) + error BUT R assumes that o = melanistic NOT typical > exp( ) = R: MINITAB: >exp( ) = SAME(ish)
R: MINITAB: >exp(0.9332) = Odds Ratio >exp( ) = >1/exp( )=2.5426
Calculating 95% Confidence Intervals CI = e Estimate±(SE*z-value) >exp(0.9332±(0.2069*1.96)) Lower = Upper=
You have reached the end of part one But there is a preliminary stab at part two
Dave’s Barnacles Tetraclita squamosa Acanthia sp. >avthickathole<-glm(formula=Npartial/N~AvThickAtHole,family=binomial, weights=N,data=test)
Average thickness at hole LM GLM
Average thickness at hole General Linear Model: >lm.avthickathole<-lm(w.wbar~AvThickAtHole,data=test) Generalized Linear Model: >avthickathole<-glm(formula=Npartial/N~AvThickAtHole,family=binomial, weights=N,data=test) Odds Ratio: 1.13 (remember…exp(0.1249))
Average thickness residuals plots LM GLM
Summary of model comparison…GLM vs LM
Height of barnacle General Linear Model: >lm(w.wbar ~ Ht, data = height) Generalized Linear Model: >glm.height<-glm(Npartial/N~Ht,family=binomial,weights=N,data=height)) Odds Ratio: 1.26
Height of barnacle residuals plots LM GLM
Summary of model comparisons…GLM vs LM
Max Diameter General Linear Model: >lm(w.wbar ~ MaxDiam, data = maxdiam) Generalized Linear Model: >glm(Npartial/N ~ MaxDiam, family = binomial, data = maxdiam,weights = N) Odds Ratio: 1.073
Max Diameter residuals plots LM GLM
Summary of model comparisons…GLM vs LM
Okay, that’s it…