Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: re: logistic function


From   Kit Baum <baum@bc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: re: logistic function
Date   Thu, 18 Jun 2009 12:42:01 -0400

<>
John wanted to do nonlinear predictions from an estimated logit model. Wikipedia (or Wolfram's MathSource) is his friend:

sysuse auto,clear
logit foreign trunk mpg  d
// mean of predictions is equal to mean of foreign in logit
su foreign, mean
scalar mu = r(mean)
su trunk, mean
scalar mut = r(mean)
su mpg, mean
scalar mum = r(mean)
// form of CDF from http://en.wikipedia.org/wiki/Logistic_distribution
scalar s = sqrt(2*c(pi)/3)
local cum1 1/(1+exp(-((_b[_cons]+ _b[trunk]*mut + _b[mpg]*mum + _b[d]*1) - mu)/s)) local cum0 1/(1+exp(-((_b[_cons]+ _b[trunk]*mut + _b[mpg]*mum + _b[d]*0) - mu)/s))
di "`cum1'"
di "`cum0'"
predictnl dfdd1= `cum1' - `cum0' in 1, se(serr1)
l dfdd1 serr1 in 1


Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html
   An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index