Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

R�p. : st: RE: Non linear least squares program, Stata versions?


From   "Diego Rei" <[email protected]>
To   <[email protected]>
Subject   R�p. : st: RE: Non linear least squares program, Stata versions?
Date   Thu, 14 Oct 2004 16:37:13 +0200

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+$XALMPHAT*talmphat+$XUDEN*`5'+$XT*tt+$XCOORD*`6')*($T2*Iperio_2+$T3*Iperio_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+$DEN*Icoun_5+$FIN*Icoun_6+$FRA*Icoun_7+$GER*Icoun_8+$IRE*Icoun_11+$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



>>> [email protected] 10/14 4:22  >>>
It is really difficult to comment helpfully without 
seeing your program. 

rc (return code) 198 just means syntax error. 

Some programmers use 198 as the return code
for almost all premature exits, although as -nl- 
is official Stata code, it really should mean 
syntax error in your case. 

Nick 
[email protected] 

Diego Rei

> I am encountering a problem  that has been discussed on the 
> list few months ago, but apparently not in a conclusive manner. 
> I am trying to run an nl program with Stata 8 and I get the 
> following error:
> invalid syntax
> nlprogt2 refused query, rc=198.
> On the list it was suggested, answering to a similar 
> question,  that this might have to do with the quoting signs  
>  ' in program lines. I checked them and they are all ok. So, 
> I tried to run the same program on an Stata 6, and it 
> actually worked. However, now, in Stata 6, if I slightly 
> alter my program, it stops with the following message: 
> nlprogt2 refused query, rc=198. Note that there doesnt appear 
> the line saying "syntax error".
> Can anyone enlighten me about what is the point here?Is there 
> a place where I can find what the meaning of "rc=198" or similar is?

*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index