[Limdep Nlogit List] help with looping
William Greene
wgreene at stern.nyu.edu
Mon Aug 24 04:56:58 EST 2009
Phil.
In the current version of NLOGIT (i.e., 4.0 and the 3.0 that you are
using), a command stream such as this must be in a procedure. The commands
can't be executed one at a time because it is only within a proceudure
that the command interpreter can look backwards at a previous command.
Note below.
Regards,
Bill Greene
--> RESET
Initializing NLOGIT Version 4.0.8 (May 1, 2009).
--> proc
--> matrix;a=Init(3,3,0)$
--> do for;10;i=1,3$
--> do for;5;j=1,3$
--> calc;ij=i*j$
--> matrix;a(i,i)=ij$
--> enddo;5$
--> enddo;10$
--> endproc
--> execute
Maximum repetitions of PROC
--> matrix;list;a$
Matrix Result has 3 rows and 3 columns.
1 2 3
+-------------+-------------+-------------+
1| 3.00000 .0000000D+00 .0000000D+00
2| .0000000D+00 6.00000 .0000000D+00
3| .0000000D+00 .0000000D+00 9.00000
+-------------+-------------+-------------+
----- Original Message -----
From: "Philip A. Viton" <viton.1 at osu.edu>
To: limdep at limdep.itls.usyd.edu.au
Sent: Sunday, August 23, 2009 12:01:34 PM GMT -05:00 Columbia
Subject: [Limdep Nlogit List] help with looping
The following is from the Limdep v. 7 manual, p. 780:
matrix;a=Init(3,3,0)$
do for;10;i=1,3$
do for;5;j=1,3$
calc;ij=i*j$
matrix;a(i,i)=ij$
enddo;5$
enddo;10$
When I run it from a new session I get:
--> RESET
Initializing NLOGIT Version 3.0.14 (August 1, 2004).
--> matrix;a=Init(3,3,0)$
--> do for;10;i=1,3$
--> do for;5;j=1,3$
--> calc;ij=i*j$
Error 464: Error in or near I*J;
Error 116: CALC - Unable to compute result. Check earlier message.
--> matrix;a(i,i)=ij$
Error 67: Matrix element in an expression has an invalid subscript.
--> enddo;5$
--> enddo;10$
This is symptomatic of problems I'm having with "real" programming in
loops - computations involving the loop indices seem to fail. Can
someone tell me what's going wrong?
Thanks!
------------------------
Philip A. Viton
City Planning, Ohio State University
275 West Woodruff Avenue, Columbus OH 43210
viton.1 at osu.edu
_______________________________________________
Limdep site list
Limdep at limdep.itls.usyd.edu.au
http://limdep.itls.usyd.edu.au
More information about the Limdep
mailing list