Note:
- Make sure to use confidence intervals where you can.
- I find it easier to talk about odds that are greater than 1. Thus, you will see that I “flipped” the odds below so I could talk about how many more times greater it was that the Ruffe had not consumed a Daphnia than it had.
- Note in question 3 that you cannot describe the relationship between the PROBABILITY and Ruffe length from the slope or the back-transformed slope; rather you must describe the shape of the curve in the fitplot. The slope tells how the log(odds) change (additively) with an increase in length and the back-transformed slope tells how the odds change (multiplicatively) with an increase in length.
Ruffe Feeding
- The fitted-line plot (Figure 1) suggests that the logistic regression model fits the proportions of larval Ruffe that had consumed a Daphnia fairly well as indicated by the relative closeness of the modeled line to the observed proportions (i.e., blue pluses).
- There is a significant relationship between the probability of consuming a Daphnia and the length of the Ruffe as indicated by a p-value for the slope of the logistic regression (p<0.00005; Table 1) that is less than 0.05.
- The relationship between the probability of having consumed a Daphnia and the length of the Ruffe cannot be described with any given number and must be described from Figure 1. From Figure 1 it is seen that this probability is “low” until about 6 mm, rises sharply to about 10 mm, and then stays high above 10 mm. Additionally, the odds of consuming a Daphnia are between 2.5388 and 6.1107 times greater for each increase of 1 mm in larval Ruffe length (back-transformed from Table 2).
- The odds that a 6-mm long larval Ruffe had consumed a Daphnia is 0.0584, which means that the probability that a 6-mm long larval Ruffe had consumed a Daphnia is only 0.0584 times the probability that it had not consumed a Daphnia. This indicates that the 6-mm long larval Ruffe was 17.1 (=\(\frac{1}{0.0584}\)) times more likely to NOT have consumed a Daphnia then it was to have consumed a Daphnia.
- The probability that a 6-mm long larval Ruffe had consumed a Daphnia is 0.0552, with a 95% confidence interval from 0.0157 to 0.1114. This means that approximately one out of every 18.1 (95% CI: 8.9735, 63.6551) 6-mm long larval Ruffe will have consumed a Daphnia.
Figure 1: Fitted plot for the logistic regression of whether or not a larval Ruffe had consumed a Daphnia and the length of the Ruffe.
Table 1: Summary of the coefficients from the logistic regression of whether or not a larval Ruffe had consumed a Daphnia and the length of the Ruffe.
Estimate Std. Error z value Pr(>|z|)
(Intercept) -10.711628 1.7543434 -6.105776 1.023023e-09
len 1.311943 0.2216996 5.917661 3.265530e-09
Table 2: Confidence intervals for the coefficients from the logistic regression of whether or not a larval Ruffe had consumed a Daphnia and the length of the Ruffe.
2.5 % 97.5 %
(Intercept) -14.6654105 -7.709509
len 0.9316978 1.810041
R Appendix.
library(NCStats)
df <- read.csv("https://raw.githubusercontent.com/droglenc/NCData/master/RuffeLarvalDiet.csv")
df <- filterD(df,loc=="Allouez")
glm1 <- glm(o.daph~len,data=df,family=binomial)
cf1 <- coef(glm1)
sum1 <- summary(glm1)
ci1 <- confint(glm1)
predProb <- function(x,alpha,beta) exp(alpha+beta*x)/(1+exp(alpha+beta*x))
p6 <- predProb(6,cf1[[1]],cf1[[2]])
bc2 <- bootCase(glm1) # bootstrapping, be patient!
p6bc <- predProb(6,bc2[,1],bc2[,2])
p6ci <- quantile(p6bc,c(0.025,0.975),na.rm=TRUE)
fitPlot(glm1,xlab="Length (mm)",ylab="Daphnia in Stomach?",breaks=seq(3.5,17.5,1))