Is my logistic regression model correct? I have a factorial design 2*2 (A and B). Both variables with two responses high (coded as 1) and low (coded as 0) and I have a response variable $y$, my logistic model include interaction between A and B in R, I coded logit<-glm(y~ A + B + A:B, data = df, family = "binomial").
I verified the data and everything is good. I even ensured the my variables are coded as factors, in the exercise I'm working on I demonstrated that (check the image) 
The $y$ in the picture are the average response.
The table used to calculate the coefficient is :

The coefficient I found using the formulas in the picture are not equal to the coefficient in the output of R (see image)

I don't understand where the problem is. I hope someone can explain to me the error I made.
Thank you.
 A: The coefficients you see in the glm() output are those in the following formulation:
$\log(\frac{p}{1-p}) = \beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2$
These coefficients do not correspond to probabilities of class membership: they are partial derivatives of the log-odds (logit) of your response variable being 1 with respect to your regressors. You can rearrange the above to give:
$\hat{p} = \frac{\exp(\beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2)}{1 + \exp(\beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2)}$
To see that this works, let's plug in CYL1=1 and SS1=0. Don't forget the intercept.
$\hat{p} = \frac{\exp(-2.9 + 0.75*1 + 1.2*0 - .39*1*0)}{1 + \exp(-2.9 + 0.75*1 + 1.2*0 - .39*1*0)} = \frac{\exp(-2.9 + 0.75)}{1 + \exp(-2.9 + 0.75)} = 0.1$
This gives us the bottom-right value in your table. Doing this for all four possibilities should give you the values in the table.
If you want to use predict() to predict the probabilities of future data, supply the type = "response" argument in order to have the output in this probability form. Otherwise, you will be given predicted log odds values.
