Hi Statalist,
After running logit, how does stata predict the probability of outcome? More importantly and specifically, how do I reproduce the results manually? Here is an example using -predict- and using my attempt at manual calculation (which is somehow wrong?) produces 2 different results. I tried manual calculation after a linear regression (eg. substituting -reg- for -logit- here) and the results of -predict- and manual calculation are the same. What am I doing wrong with my manual calculation after -logit-?
Ultimately, I'm trying to calculate an elasticity manually and the results after running -logit- are not the same compared with using -margins, eyex- Again, the code below works for a linear regression but not logit. What am I missing? Do I need to somehow take into account the logit link? If so how?
Thanks!
After running logit, how does stata predict the probability of outcome? More importantly and specifically, how do I reproduce the results manually? Here is an example using -predict- and using my attempt at manual calculation (which is somehow wrong?) produces 2 different results. I tried manual calculation after a linear regression (eg. substituting -reg- for -logit- here) and the results of -predict- and manual calculation are the same. What am I doing wrong with my manual calculation after -logit-?
Code:
**Load example dataset sysuse auto, clear **Regression qui: logit foreign price **Stata predicted probability predict yhat **Calc predicted probability manually gen yhat2 = (price*_b[price] + _b[_cons]) sum yhat yhat2
Code:
///First by automated method (eyex) **Load example dataset sysuse auto, clear **Regression qui: logit foreign price **Predict elasticities margins, eyex(price) nose ///Second by manual method **Load example dataset sysuse auto, clear **Regression qui: logit foreign price **Calc eyex *Denominator gen denom = (price*_b[price] + _b[_cons]) *Numerator gen numer = (price*_b[price]) *Eyex gen price_eyex = (numer/denom) sum price_eyex
Comment