?=============================================================== ? Replication of Computations in Ai and Norton (2003) ? Based on the 1988 observations in RWM, JAE (2003) ? DOCTOR, the dependent variable, is 1 if the individual reports ? at least 1 visit to the doctor in the observation year. ? Case 1. a model with an interaction "effect" but no product ? term. The interaction is between age and income. ? Partition the regressor vector. ?=============================================================== Sample ; All $ Namelist ; z =one,educ,female,hhkids,married $ Namelist ; all = hhninc,age,z $ Probit ; Lhs = doctor ; Rhs = all$ ?=============================================================== ? The first two variables are the ones that are interacting. ?=============================================================== Calc ; dh = b(1) ; da = b(2) $ Create ; all_b = all'b ; density = n01(all_b) ; f = phi(all_b) ? Function ; fp = density ? First deriv. ; fpp = -density * all_b ? Second deriv. ; fppp = density * (all_b^2 - 1)$ ? Third deriv. ?=============================================================== ? Interaction effect and derivatives for delta method ?=============================================================== Create ; inteff = dh*da*fpp $ Create ; g1 = da*fpp + da*dh*fppp*hhninc ; g2 = dh*fpp + da*dh*fppp*age ; g3 = dh*da*fppp ? Constant term ; g4 = g3*educ ; g5 = g3*female ; g6 = g3*hhkids ; g7 = g3*married $ Namelist ; g = g1,g2,g3,g4,g5,g6,g7 $ ? Jacobian ?=============================================================== ? Standard errors computed for every observation ?=============================================================== Create ; sd = sqr(qfr(g,varb)) ; t_ratio = inteff/sd $ Dstat ; rhs=inteff,t_ratio$ ?=============================================================== ? Draw a random sample to plot. Set the seed so that this is ? replicable. ?=============================================================== Calc ; Ran (123479) $ Draw ; N=2733 $ Plot ; lhs= f ; rhs = t_ratio ; bars = 2,1.96,0,-1.96,-2 ; Spikes=.5 ; grid ; Title=T Ratios on Interaction Terms vs. Probability ; Vaxis=Individual t ratios ; Footer=Fitted Probability$ plot;lhs= f ; rhs = inteff ; bars = 0 $ dsta;rhs=t$ ?=============================================================== ? Standard errors and t ratios for the index function ?=============================================================== samp;all$ create ; sdindex=sqr(qfr(all,varb)) ; tindex = all_b/sdindex $ dstat;rhs=tindex $ ?=============================================================== ?=============================================================== ?=============================================================== ?=============================================================== ?=============================================================== ?=============================================================== ? Examine Partial Effects graphically Sample ; All $ Namelist ; z=one,educ,hhninc,hhkids,married $ Probit ; Lhs = doctor ; Rhs = female,age,z$ Calc ; df = b(1) ; da = b(2) $ Matrix ; bz = b(3:7) ; zbar = Mean(z) ; bzz = bz'zbar $ Create ; pd0 = phi( da*age + bzz) ; pd1 = phi(df + da*age + bzz) $ Calc ; Ran (123479) $ Draw ; N=2733 $ Plot ; lhs = age ; rhs = pd0,pd1 ; fill $ ? Model with interaction effects. Just examine partial effect ? graphically. Sample ; All $ Create ; int = female*age$ Probit ; lhs = doctor ; Rhs = female,age,int,one,educ,hhninc,hhkids,married $ Matrix ; bz = b(4:8) ; bzz = bz'zbar $ Calc ; df = b(1) ; da = b(2) ;di = b(3) $ Create ; pd0i = phi( da*age + bzz) ; pd1i = phi(df + da*age + di * age + bzz) $ Calc ; Ran (123479) $ Draw ; N=2733 $ Plot ; lhs = age ; rhs = pd0i,pd1i ; fill $ ? Plot results from both models in the same figure Plot ; lhs = age ; rhs = pd0,pd1,pd0i,pd1i ; fill ;grid ;title=Fitted Probabilities for Models with Interaction Terms ;Vaxis=Fitted Probabilities (Other Variables Fixed At Means)$ ?================================================================ ? Miscellaneous stuff Create ; g1 = fppp*hhninc ; g2 = fppp*age ; g3 = fppp ? Constant term ; g4 = fppp*educ ; g5 = fppp*female ; g6 = fppp*hhkids ; g7 = fppp*married $ Namelist ; g = g1,g2,g3,g4,g5,g6,g7 $ ? Standard errors computed for every observation Create ; sd = sqr(qfr(g,varb)) ; t_ratio = fpp/sd $ dstat;rhs=fpp,t_ratio$ samp;all$ Namelist ; z =one,educ,female,hhkids,married $ Namelist ; all = hhninc,age,z $ create ; hinc_age = hhninc*age $ Probit ; Lhs = doctor ; Rhs = hhninc,age,hinc_age,z ;cluster=id$$ calc;d1=-.5;d2=.5;d12=.5;d0=-1$ calc;list ;df0=phi(d0+d1)-phi(d0) ;df1=phi(d0+d1+d2+d12)-phi(d0+d1) ;inteff=df1-df0$ calc;list ;df0=phi(d0+d1)-phi(d0) ;df1=phi(d0+d1+d2)-phi(d0+d1) ;inteff=df1-df0$