Skip to main content
2 of 2
Added a section explaining the prediction if "rank" is at its reference level.
COOLSerdash
  • 31.2k
  • 10
  • 104
  • 157

Your manual calculation is correct in terms of the coefficients, but you lose precision by either rounding incorrectly (i.e. the coefficient of the interaction) or by just not using enough numbers after the decimal point. Here is the manual calculation using 5 significant digits: $$ \mathrm{logit}(y) = -13.609 + 0.018344\cdot 380 + 3.6522\cdot 3.61 - 1.3435\cdot 1 -0.004719\cdot 380\cdot 3.61 = -1.270862 $$ The corresponding probability is: $$ \exp(-1.270862)/(1 + \exp(-1.270862)) = 0.2191 $$

Which is in good agreement with the more precise result from predict which uses the full precision available.

Edit

What if instead of the prediction for rank3 we'd like to predict for an individual with rank1 which is the reference value of the categorical variable rank? In the current dummy coding scheme, the coefficients for rank2-rank4 are the differences in the log-odds between the reference category and the respective level. Thus, the coefficient for the reference category is the intercept. Hence, the predicted log-odds in this situation are simply:

$$ \mathrm{logit}(y) = -13.609 + 0.018344\cdot 380 + 3.6522\cdot 3.61 -0.004719\cdot 380\cdot 3.61 = 0.0726378 $$ and the corresponding probability is $0.5181515$.

COOLSerdash
  • 31.2k
  • 10
  • 104
  • 157