[Limdep Nlogit List] Create a selection matrix

Richard Lo eroica2joy at googlemail.com
Sat May 15 00:19:12 EST 2010


Dear All,
I have two namelists (X1, X2) and want to create a selection matrix J2 such
that XJ2=X2 (where X is the namelist for the union of X1 and X2).
Matrix J2 consists of 1's and 0's. To assign these values to the cells of
matrix J2, I have to make a comparion of two strings using conditional
command.
If the ith variable in X is the same as the jth variable in X2, then the
(i,j) cell will have a value of one, 0 otherwise.
I create a routine to do the job (using the indexing variables in
namelists), but an error message
"Error  565: IF(... or REJECT... Cannot ID string ..." always occurs for the
Matrix; if command .
I have tried several ways to solve this problem, Still, I can not figure out
how to do a valid string comparison in Limdep. My code is listed below for
reference.

----------------------------------------
NAMELIST  ; X1 =......;  X2 = .......  $

PROC  = MatrixJ2(X1,X2) $    Creates selection matrix J2
NAMELIST; X = OR(X1,X2) $    Forms the union of the exogenous variables.
CALC   ; JR=Col(X);  JC=Col(X2)$
MATRIX ; J2=init(JR,JC,0) $
DO FOR ; 10; i=1, JR$
DO FOR ; 5; j=1, JC$
*MATRIX ; If(X:i = X2:j) J2(i,j)=1; (Else) J2(i,j)=0 $*
ENDDO  ; 5$
ENDDO  ; 10$
ENDPROCEDURE $
EXECUTE ; Proc = MatrixJ2(X1, X2) $
--------------------------------------------

Any advice on how to solve the above problem would be highly appreciated.


Richard Lo


More information about the Limdep mailing list