I would like to plot the line and the shaded 95% confidence interval bands (for example using polygon)from a glm model (family binomial). For linear models (lm), I have previously been able to plot the confidence intervals from the predictions as they included the fit, lower and upper level see e.g. this answer How to plot regression transformed back on original scale with colored confidence interval bands? but I do not know how to do it here. Thanks for help in advance. You can find here the data that I used (it contains 3 variables and 4582 observations): https://drive.google.com/file/d/1RbaN2vvczG0eiiqnJOKKFZE9GX_ufl7d/view?usp=sharing Code and figure here:
# Models
hotglm=glm(hotspot~age+I(age^2),data = data, family = "binomial")
summary(hotglm)
coldglm=glm(coldspot~age+I(age^2),data = data, family = "binomial")
summary(coldglm)
# Plot
age = 1:200
lin=hotglm$coefficients[1]+hotglm$coefficients[2]*age+hotglm$coefficients[3]*age^2
pr = exp(lin)/(1+exp(lin))
par(mfrow=c(1,1))
plot(age, pr,type="l",col=2,lwd=2,ylim=c(0,.15))
lin=coldglm$coefficients[1]+coldglm$coefficients[2]*age+coldglm$coefficients[3]*age^2
pr = exp(lin)/(1+exp(lin))
lines(age, pr,type="l",col="blue", lwd=2)