- Note that your confidence interval values may be slightly different than mine because there is an inherent randomization that occurs with bootstrapping. They should not be very different.
Ruffe Feeding
- There is a significant relationship between the probability that the Ruffe consumed a Daphnia and the length of the Ruffe (LRT p<0.00005).
- The slope says that as the length of the Ruffe increases by one mm then the log odds of having consumed a Daphnia increases between 1.018 and 1.938.
- The exponentiated slope says that as the length of the Ruffe increases by one mm then the odds of having consumed a Daphnia is between 2.768 and 6.944 times greater.
- The probability that a 6-mm Ruffe will have consumed a Daphnia is between 0.013 and 0.108. Thus, only between 1.3% and 10.8% of 6-mm Ruffe are likely to have consumed a Daphnia.
- The odds that a 6-mm Ruffe will have consumed a Daphnia is 0.058. Thus, it is 17.115 times more likely that a 6-mm Ruffe has NOT consumed a Daphnia than it is that it HAS consumed a Daphnia.
- The length where 50% of Ruffe have consumed a Daphnia is between 7.756 and 8.570 mm.
- The length where 90% of Ruffe have consumed a Daphnia is between 9.118 and 10.533 mm.
- The best-fit logistic regression line is shown below.
R Code and Results
> predProb <- function(x,alpha,beta) exp(alpha+beta*x)/(1+exp(alpha+beta*x))
> predX <- function(p,alpha,beta) (log(p/(1-p))-alpha)/beta
> Ruffe <- read.csv("https://raw.githubusercontent.com/droglenc/NCData/master/RuffeLarvalDiet.csv")
> Ruffe <- filter(Ruffe,loc=="Allouez")
> Ruffe$daph01 <- ifelse(Ruffe$o.daph=="Y",1,0)
> glm.Ruffe <- glm(daph01~len,data=Ruffe,family=binomial)
> anova(glm.Ruffe,test="LRT")
Analysis of Deviance Table
Model: binomial, link: logit
Response: daph01
Terms added sequentially (first to last)
Df Deviance Resid. Df Resid. Dev Pr(>Chi)
NULL 163 218.467
len 1 130.81 162 87.659 < 2.2e-16
> boot.Ruffe <- car::Boot(glm.Ruffe)
> cbind(Est=coef(glm.Ruffe),confint(boot.Ruffe,type="perc"))
Est 2.5 % 97.5 %
(Intercept) -10.711628 -15.934001 -8.322682
len 1.311943 1.007326 1.953905
> nd <- data.frame(len=6)
> ( lodds6 <- predict(glm.Ruffe,newdata=nd) )
1
-2.83997
> exp(lodds6)
1
0.05842739
> ( prob6 <- predict(glm.Ruffe,newdata=nd,type="response") )
1
0.05520208
> prob6.boot <- predProb(6,boot.Ruffe$t[,1],boot.Ruffe$t[,2])
> ( prob6.ci <- quantile(prob6.boot,probs=c(0.025,0.975),type=1) )
2.5% 97.5%
0.01237052 0.10864974
> x50.boot <- predX(0.5,boot.Ruffe$t[,1],boot.Ruffe$t[,2])
> ( x50.ci <- quantile(x50.boot,probs=c(0.025,0.975),type=1) )
2.5% 97.5%
7.722297 8.586595
> x90.boot <- predX(0.9,boot.Ruffe$t[,1],boot.Ruffe$t[,2])
> ( x90.ci <- quantile(x90.boot,probs=c(0.025,0.975),type=1) )
2.5% 97.5%
9.141231 10.546048
> ggplot(data=Ruffe,mapping=aes(x=len,y=daph01)) +
geom_point(alpha=0.1) +
geom_smooth(method="glm",method.args=list(family=binomial)) +
labs(x="Total Length (mm)",y="Probability of Consuming a Daphnia") +
theme_NCStats()