# How to calculate confidence bands for a regression line, given intercept, slope, and standard errors

I have the following set of model-averaged fixed effects from a set of binomial GLMMs:

I would like to plot the predicted effect of "NBT", along with confidence bands, while holding all the other variables at their baseline levels. My attempt to do this in ggplot:

Xvars <- seq(from=0, to=100, by=0.1)  #NBT range is 0-100
binomIntercept <- 1.317
binomSlope <- -0.0076
binomSE <- 0.009
Means <- logistic(binomIntercept + binomSlope*Xvars)
loCI <- logistic(binomIntercept + (binomSlope - 1.96*binomSE)*Xvars)
upCI <- logistic(binomIntercept + (binomSlope + 1.96*binomSE)*Xvars)
df <- data.frame(Xvars,Means,loCI,upCI)
p <- ggplot(data=df, aes(x = Xvars, y = Means)) +
geom_line() +
geom_line(data=df, aes(x = Xvars, y = upCI),col='grey') +
geom_line(data=df, aes(x = Xvars, y = loCI), col='grey')
p


I'm assuming that the confidence bands are cone shaped because I'm not accounting for uncertainty in the estimate for the intercept. Maybe this is okay (?), but it does look different from every regression line I've ever seen with confidence intervals plotted.

Can someone please tell me how I should be writing my equations to get the correct confidence intervals, given the intercept, slope, and standard errors from my model output?

(I know I can use the predict function to do this in R, but would like to know how to do it by hand.)

• Can you please check your links (404 error)? You can use imgur.com to share images, or better copy-paste output as plain text for model results.
– chl
Dec 24, 2013 at 13:19
• Charlie gave a good general answer to this question at stats.stackexchange.com/questions/15423/… which might help set you on the right path.
– whuber
Dec 26, 2013 at 17:10
• thanks @whuber, that gives me a good starting point. Is taking me a while to digest his answer but should be able to figure it out from there. Cheers
– jay
Dec 28, 2013 at 22:05