If an error occurs in the initialization section of a -nl- program, you can
find it by setting the trace to "on" and calling your program directly with
a "?" argument (instead of calling it through Stata's -nl- command. For
example, suppose the name of your program is nlfoo.ado.
Then issue the following commands:
set trace on
nlfoo "?"
This trick can also be used for the iteration section, but you have to be
prepared to have your dependent variable replaced. So set a new variable
(say "temp") equal to your DV first. For example, suppose your DV is "y":
gen temp = y
set trace on
nlfoo temp [plus other arguments, if necessary]
Al Feiveson
-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Nick Cox
Sent: Thursday, October 14, 2004 11:52 AM
To: [email protected]
Subject: st: RE: R�p. : st: RE: Non linear least squares program, Stata
versions?
In your second program you are declaring, among other
parameters, XKENWCOOR in your S_1 but initialising
XKENWCOO to 0.
XKENWCOOR is thus not initialised and will get
read by Stata as denoting empty. The result will
probably be the syntax error reported.
Nick
[email protected]
Diego Rei
> Thank you Nick. I will just post the two programs.
> The first one is the one that works with Stata 6 but not with Stata8.
> The second one is the one that doesnt work with either. I
> hope they are not too cumbersome.
>
> This works:
> program define nlprogt2
> if "`1'" == "?" {
> global S_1 "T2 T3 T4 T5 T6 T7 T8 XRRATE
> XBENEFIT XUNION XEMPRO XALMPHAT XUDEN XT XCOORD AUS AUT BEL
> CAN DEN FIN FRA GER IRE ITA JAP NET NOR NZ POR SPA SWE SWZ UK USA"
> global AUS=0
> global AUT=0
> global BEL=0
> global CAN=0
> global DEN=0
> global FIN=0
> global FRA=0
> global GER=0
> global IRE=0
> global ITA=0
> global JAP=0
> global NET=0
> global NOR=0
> global NZ=0
> global POR=0
> global SPA=0
> global SWE=0
> global SWZ=0
> global UK=0
> global USA=0
> global T2=0.00
> global T3=0.00
> global T4=0.00
> global T5=0.00
> global T6=0.00
> global T7=0.00
> global T8=0.00
> global XRRATE=0
> global XBENEFIT=0
> global XUNION=0
> global XEMPRO=0
> global XALMPHAT=0
> global XUDEN=0
> global XT=0
> global XCOORD=0
> exit
> }
> replace `1' =
> ($XRRATE*`2'+$XBENEFIT*`3'+$XEMPRO*`4'+$XUNION*tunion+$XALMPHA
> T*talmphat+$XUDEN*`5'+$XT*tt+$XCOORD*`6')*($T2*Iperio_2+$T3*Ip
> erio_3+$T4*Iperio_4+$T5*Iperio_5+$T6*Iperio_6+$T7*Iperio_7+$T8
> *Iperio_8)+$T2*Iperio_2+$T3*Iperio_3+$T4*Iperio_4+$T5*Iperio_5
> +$T6*Iperio_6+$T7*Iperio_7+$T8*Iperio_8
> replace
> `1'=`1'+$AUS*Icoun_1+$AUT*Icoun_2+$BEL*Icoun_3+$CAN*Icoun_4+$D
> EN*Icoun_5+$FIN*Icoun_6+$FRA*Icoun_7+$GER*Icoun_8+$IRE*Icoun_1
> 1+$ITA*Icoun_12+$JAP*Icoun_13+$NET*Icoun_17+$NOR*Icoun_18+$NZ*
> Icoun_19+$POR*Icoun_20+$SPA*Icoun_21+$SWE*Icoun_22
> +$SWZ*Icoun_23+$UK*Icoun_25+$USA*Icoun_26
> end
>
> set more on
>
> nl progt2 unr trrate tbenefit tempro tuden tcoord if tshock
>
>
> This doesnt:
>
> program define nlprogt2
> if "`1' " == "?" {
> global S_1 "T2 T3 T4 T5 T6 T7 T8 XEP XUD XBRR
> XBD XTW XCBI XKENWCOOR AUS AUT BEL CAN DEN FIN FRA GER IRE
> ITA JAP NET NOR NZ SWE SWZ UK USA"
> global AUS=0
> global AUT=0
> global BEL=0
> global CAN=0
> global DEN=0
> global FIN=0
> global FRA=0
> global GER=0
> global IRE=0
> global ITA=0
> global JAP=0
> global NET=0
> global NOR=0
> global NZ=0
> global SWE=0
> global SWZ=0
> global UK=0
> global USA=0
> global T2=0.00
> global T3=0.00
> global T4=0.00
> global T5=0.00
> global T6=0.00
> global T7=0.00
> global T8=0.00
> global XEP=0
> global XUD=0
> global XBRR=0
> global XBD=0
> global XTW=0
> global XCBI=0
> global XKENWCOO=0
> exit
> }
> replace `1' =
> ($XEP*`2'+$XUD*`3'+$XBRR*`4'+$XBD*`5'+$XTW*`6'+$XCBI*`7'
> +$XKENWCOOR*`8')*($T2*ye2+$T3*ye3+$T4*ye4+$T5*ye5+$T6*ye6+$T7*
> ye7+$T8*ye8)+$T2*ye2+$T3*ye3+$T4*ye4+$T5*ye5+$T6*ye6+$T7*ye7+$T8*ye8
> replace
> `1'=`1'+$AUS*ce1+$AUT*ce2+$BEL*ce3+$CAN*ce4+$DEN*ce5+$FIN*ce6+
> $FRA*ce7+$GER*ce8+$IRE*ce11+$ITA*ce10+$JAP*ce11+$NET*ce12+$NZ*
> ce13+$NOR*ce14+$SWE*ce17 +$SWZ*ce18+$UK*ce19+$USA*ce20
> end
>
> set more on
>
> nl progt2 unr tep tud_alt tbrr tbd ttw tcbi tkenwcoo if tshock
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/