In trying to understand logistic regression, I find it easiest to transform the coefficients into predicted probabilities. So, for a particular predictor value (x):
precicted probability = 1 / (1 + exp(-(intercept + slope * x)))
Using the 'predict' function, I'll exemplify as:
# Generate data
set.seed(42)
n <- 90
x <- sort(sample(seq(1, 90, by = 1), n, replace = T))
y <- rbinom(n, c(1, 0), c(seq(0, 1, length.out = n), seq(1, 0, length.out = n)))
############ Apply logistic regression ##########
m1 <- glm(y ~ x, family = 'binomial')
############ Interpreting logistic regression ##########
new <- data.frame(x = seq(1, 90, by = 1))
pred <- predict.glm(m1, newdata = new, type = "response")
plot(x, m1$fitted.values, ylim = c(0, 1))
lines(new$x, pred)
My question, then, is if I can interpret the confidence intervals around the coefficients for logistic regression in terms of predicted probability too. That is, like:
############ Interpreting confidence intervals ##########
confs <- confint(m1)
ll <- 1 / (1 + exp(-(confs[1, 1] + confs[2, 2] * new$x)))
ul <- 1 / (1 + exp(-(confs[1, 2] + confs[2, 1] * new$x)))
lines(new$x, ll, col = "red")
lines(new$x, ul, col = "green")
I believe the two colored lines (are not prediction intervals but) illustrate the limits of the relationship between the predictor and outcome variable we can be 95% confident in based on this data. Is this so?