I am trying to reproduce the following example of logistic regression with a transformed linear regression:
am.glm <- glm(am ~ hp + wt, data=mtcars, family=binomial)
newdata <- data.frame(hp=120, wt=2.8)
predict(am.glm, newdata, type="response")
## 1
## 0.6418125
The equation for the probability of $Y=1$ is the following: $$ P(Y=1) = {1 \over 1+e^{-(b_0+\sum{(b_iX_i)})}} $$
So I tried something like this:
am.lm <- lm(am ~ 1/(1+exp(-(hp + wt))),data=mtcars)
predict(am.lm, newdata)
## 1
## 0.40625
So this is obviously wrong! (I also tried transforming the given value but nothing worked so far).
My question
How would I have to set up logistic regression with explicitly specifying the formula for the non-linear transformation of the linear model?