?=================================================================== ? Sample selection model with DISCRETE CHOICE selection. = ? Requires modification at all points marked by *'s below. = ? Assumes 3 attributes in choice model. Changes needed if more. = ?=================================================================== SAMPLE ; All $ (*) CREATE ; Choice = Trn(-4,0) $ (*) NAMELIST ; V = z1,z2,z3 $ (*) DISCRETE ; Lhs = z ; Rhs = V ; RES = P $ (Saves probabilities) MATRIX ; alpha = b ; SG = varb $ (*) REJECT ; new ; choice # 2 $ ? ? To create the within observation deviation for the j'th choice, we treat the ? 4 rows of data as if they were separate observations. Using the lag and lead ? operators, we can access the attributes within each observation relative to ? a particular choice within the observation. If, for example, we were select- ? ing on choice 3 instead of 2, the four rows would be accessed by rejecting ? choice not equal to 3, then the lags in the command would be [-2], [-1], none, ? and [+1], respectively. ? CREATE ; H = inp(P) ; lambda = n01(H) / phi(H) ; delta = lambda * (H + lambda) (*) ; g1 = delta * (z1 - (*) (p[-1]*z1[-1] + p*z1 + p[+1]*z1[+1] + p[+2]*z1[+2]) ) (*) ; g2 = delta * (z2 - (*) (p[-1]*z2[-1] + p*z2 + p[+1]*z2[+1] + p[+2]*z2[+2]) ) (*) ; g3 = delta * (z3 - (*) (p[-1]*z3[-1] + p*z3 + p[+1]*z3[+1] + p[+2]*z3[+2]) ) ; t = 1 - rhojsq * delta $ (*) NAMELIST ; W = lambda, $ (*) REGRESS ; lhs = y ; rhs = W $ User must define NAMELIST W. CALC ; thetajsq = b(1) ^ 2 ; sigmajsq = sumsqdev / n + thetajsq * xbr(delta) ; rhojsq = thetajsq / sigmajsq $ SAMPLE ; All $ (*) NAMELIST ; G = g1,g2,g3 $ MATRIX ; FP = xdot(W,G,delta) ; PSI = sigmajsq * xdot(W,W,t) & thetajsq * FP | SG | FP' ; C = xpxi(W) | PSI | xpxi(W) ; stat(B,C) $