?=================================================================== ? Predicted probabilities for the multinomial logit model = ? = ? 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 set up columns for predicted probabilities with: = ? CREATE ; P0 = 0 ; P1 = 0 ; ... ; PJ = 0 $ = ? NAMELIST ; Probs = P0, P1, ..., PJ $ = ?=================================================================== ? LOGIT ; Lhs = y ; Rhs = X $ ? ? Problem size and some counters ? CALC ; Nolist ; K = col(X) ; jplus1 = col(Probs) ; i = 2 ; i1=1 ; i2=K $ ? ? Parameters are in a vector á. Arrange in a matrix [á1,á2,...] ? MATRIX ; Nolist ; ones = init(jplus1,1,1) ; beta=init (k,jplus1,0) $ LABEL ; 100 $ MATRIX ; Nolist ; bj=part(b,i1,i2) ;beta(*,i)=bj $ CALC ; Nolist ; i1=i1+k;i2=i2+k;i=i+1 $ GO TO ; 100 ; i <= jplus1 $ ? ? Now assemble fitted probabilities. Note use of a loop over variables. ? MATRIX ; Probs = Indx(X,Beta) $ PROCEDURE CREATE ; :Pj = exp(:Pj) $ ENDPROC EXECUTE ; :Pj = Probs $ CREATE ; Sum = DOT(Probs,ones) $ PROCEDURE CREATE ; :Pj = :Pj / Sum $ ENDPROC EXECUTE ; :Pj = Probs $