Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Omitted Variable in Logit Model


From   Arild Blekesaune <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Omitted Variable in Logit Model
Date   Sun, 24 Nov 2013 01:34:40 +0000

Dear Statalisters,

I try to estimate the effects of an omitted variable x2, and by the Law of Iterated Expectations I expect the following probability (after having expected out x2, that is, averaged the probability over the values of x2):
P(D=1|x1, x2 accounted for as an unobservable) = 
P(x2=0)*exp(b0 + b1*x1)/[1 + exp(b0 + b1*x1)] + P(x2=1)*exp(b0 + b1*x1 + b2)/[1 + exp(b0 + b1*x1 + b2)] =
(1-p)*exp(b0 + b1*x1)/[1 + exp(b0 + b1*x1)] + p*exp(b0 + b1*x1 + b2)/[1 + exp(b0 + b1*x1 + b2)] 
If the omitted variable x2 is equal to 0, the correct logit equation is: 
P(D=1|x1,x2=0) = exp(b0 + b1*x1)/[1 + exp(b0 + b1*x1)] 
If the omitted variable x2 is equal to 1, the correct logit equation is: 
P(D=1|x1,x2=1) = exp(b0 + b1*x1 + b2)/[1 + exp(b0 + b1*x1 + b2)] 
Can any of you tell me what is wrong with this attempt:
input y x1 x2 N
0 0 0 50
1 0 0 50
0 1 0 40
1 1 0 60
0 0 1 60
0 1 1 40
1 0 1 50
1 1 1 50
end
expand N in 1/8
program define user_logit
args lnf theta1 theta2
tempvar p P_11 P_10 P_1 P_0
quietly gen double `P_11' = (exp(`theta1')/(1+exp(`theta1')))*`p'
quietly gen double `P_10' = (exp(`theta2')/(1+exp(`theta2')))*(1-`p')
quietly gen double `P_1' = `P_11'+`P_10'
quietly gen double `P_0' = (1-`P_11')+(1-`P_10')
quietly replace `lnf' = $ML_y1*ln`P_1'+(1-$ML_y1)*ln`P_0'
end
ml model lf user_logit (y = x1 x2) (y = x1)
ml maximize

Thank you very much for any help.
Sincerely,

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index