?=================================================================== ? Marginal effects for the DISCRETE CHOICE model. = ? All marginal effects are a multiple of the coefficient vector. = ? dPj/dxl = r(j,l) * beta = ? The following computes the matrix of scale factors r(j,l) = ? User must define the data matrix with the following line: = ? = ? NAMELIST ; X = ... $ = ? = ? User's dependent variable is Y. Change the following line = ? = ? CREATE ; Y = the dependent variable $ = ? = ? User must also modify DISC command below for the choice set. = ?=================================================================== ? Estimate model first. This is the only command that must be set by the user. ? DISC ; Lhs = Y ; Rhs = X ; Choices = ... $ ? ? Pick up number of regressors, number of probabilities. ? CALC ; k = col(X) ; J = max(choice) ; minusJ = -J ; sumebx = 0 $ ? ? Creates indicator of choice, 1,2,3,4,1,2,3,4,... ? CREA ; choice = trn(minusJ,0) $ ? ? Set up for a matrix of means of x's by the J choices. ? MATRIX ; means=init(j,k,0) ; ones=init(j,1,1) $ ? ? The procedure will loop over the J choices, ? injecting vectors into the matrix ? PROCEDURE REJECT ; New ; choice # i $ MATRIX ; xbr = mean(X) ; means(i,*) = xbr $ ENDPROC EXECUTE ; i=1,J $ ? ? Compute vector of probabilities at means of regressors ? MATRIX ; ebx = means | b ; ebx = expn(ebx) ; sumebx=ebx' | ones $ MATRIX ; prob = 1/sumebx * ebx $ ? ? Double loop to fill cells of matrix using the probabilities. Then display. ? MATRIX ; scale=init(j,j,0) $ PROCEDURE CALC ; l=1 $ LABEL ; 10 $ CALC ; m=1 $ LABEL ; 20 $ CALC ; me=eql(l,m)*prob(l)-prob(l)*prob(m) $ MATRIX ; scale(l,m)=me $ CALC ; m=m+1 $ GO TO ; 20 ; m <= j $ CALC ; l=l+1 $ GO TO ; 10 ; l <= j$ ENDPROCEDURE EXECUTE MATRIX ; Scale$