Statalist


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

st: RE: re: logistic function


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: re: logistic function
Date   Thu, 18 Jun 2009 17:58:51 +0100

In addition, or alternatively, check out -invlogit()-. 

Nick 
[email protected] 

Kit Baum

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

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index