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

RE: st: -nl- error message


From   "Terra Curtis" <terra.curtis@cambridgefinance.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: -nl- error message
Date   Mon, 8 Aug 2005 11:02:04 -0400

So I ran my code after setting trace on ('set trace on') and I think I may
have found a bug in STATA itself.  I saved the trace as a log file and the
part concerning the invalid syntax appears here:

Iteration 0:    - if "`trace'"!="" { noi di }
  = if ""!="" { noi di }
  - }
  - local j 1
  - while `j' <= `np' {
  = while 1 <= 23 {
  - local old_pj = ${``j''}
  = local old_pj = 
invalid syntax

It appears that the problem lies deeper than in my .do file.  The last line
before "invalid syntax" shold report that old_pj equals 1 (i.e. = local
old_pj = 1).  Any ideas if this is a bug, and if so, how to go about fixing
it?

Thanks,
Terra

 

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Jonathan Beck
Sent: Monday, August 08, 2005 8:02 AM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: -nl- error message

Terra,

i have the impression that you are mixing -nl-code for different versions
here. you announce "version 8.1", but then later refer to options only
available in stata 9: "variables(.) parameters(.) nparameters(.)".

also, i have never seen a construct like "by [variable]: replace `1'=
[expression] if [variable]==1"
in an nl-program before...

my (non-experienced programmer's) advice: try to write an nl-program which
is as similar as possible to the examples in the manual!

hope this helps
jonathan



Terra wrote:
------------------------
Date: Fri, 5 Aug 2005 16:37:21 -0400
From: "Terra Curtis" <terra.curtis@cambridgefinance.com>
Subject: st: -nl- error message

I am running a nonlinear regression and have written the program which
specifies the equation:

program nlalpha_effects

version 8.1

if "`1'" == "?" {

global S_1 "BO B1 AM0 AM1 AM2 AM3 AM4 AM5 AM6 AM7 AM8 AM9 B2 AR0 AR1 AR2 AR3
AR4 AR5 AR6 AR7 AR8 AR9"

global B0=1

global B1=1

global AM0=1

global AM1=1

global AM2=1

global AM3=1

global AM4=1

global AM5=1

global AM6=1

global AM7=1

global AM8=1

global AM9=1

global B2=1

global AR0=1

global AR1=1

global AR2=1

global AR3=1

global AR4=1

global AR5=1

global AR6=1

global AR7=1

global AR8=1

global AR9=1

exit

}

by coname: replace `1'=$B0+$B1*($AM0*imktg[T]) + $B2*($AR0*ireal46[T]) if
T==1
by coname: replace `1'=$B0+$B1*($AM0*imktg[T] + $AM1*imktg[T-1]) +
$B2*($AR0*ireal46[T] + $AR1*ireal46[T-1]) if T==2 by coname: replace
`1'=$B0+$B1*($AM0*imktg[T] + $AM1*imktg[T-1] +
$AM2*imktg[T-2]) + $B2*($AR0*ireal46[T] + $AR1*ireal46[T-1] +
$AR2*ireal46[T-2]) if T==3
by coname: replace `1'=$B0+$B1*($AM0*imktg[T] + $AM1*imktg[T-1] +
$AM2*imktg[T-2] + $AM3*imktg[T-3]) + $B2*($AR0*ireal46[T] +
$AR1*ireal46[T-1] + $AR2*ireal46[T-2] + $AR3*ireal46[T-3]) if T==4 by
coname: replace `1'=$B0+$B1*($AM0*imktg[T] + $AM1*imktg[T-1] +
$AM2*imktg[T-2] + $AM3*imktg[T-3] + $AM4*imktg[T-4]) + $B2*($AR0*ireal46[T]
+ $AR1*ireal46[T-1] + $AR2*ireal46[T-2] + $AR3*ireal46[T-3] +
$AR4*ireal46[T-4]) if T==5 by coname: replace `1'=$B0+$B1*($AM0*imktg[T] +
$AM1*imktg[T-1] + $AM2*imktg[T-2] + $AM3*imktg[T-3] + $AM4*imktg[T-4] +
$AM5*imktg[T-5]) + $B2*($AR0*ireal46[T] + $AR1*ireal46[T-1] +
$AR2*ireal46[T-2] + $AR3*ireal46[T-3] + $AR4*ireal46[T-4] +
$AR5*ireal46[T-5]) if T==6
by coname: replace `1'=$B0+$B1*($AM0*imktg[T] + $AM1*imktg[T-1] +
$AM2*imktg[T-2] + $AM3*imktg[T-3] + $AM4*imktg[T-4] + $AM5*imktg[T-5] +
$AM6*imktg[T-6]) + $B2*($AR0*ireal46[T] + $AR1*ireal46[T-1] +
$AR2*ireal46[T-2] + $AR3*ireal46[T-3] + $AR4*ireal46[T-4] +
$AR5*ireal46[T-5] + $AR6*ireal46[T-6]) if T==7 by coname: replace
`1'=$B0+$B1*($AM0*imktg[T] + $AM1*imktg[T-1] + $AM2*imktg[T-2] +
$AM3*imktg[T-3] + $AM4*imktg[T-4] + $AM5*imktg[T-5] + $AM6*imktg[T-6] +
$AM7*imktg[T-7]) + $B2*($AR0*ireal46[T] + $AR1*ireal46[T-1] +
$AR2*ireal46[T-2] + $AR3*ireal46[T-3] + $AR4*ireal46[T-4] +
$AR5*ireal46[T-5] + $AR6*ireal46[T-6] +
$AR7*ireal46[T-7]) if T==8
by coname: replace `1'=$B0+$B1*($AM0*imktg[T] + $AM1*imktg[T-1] +
$AM2*imktg[T-2] + $AM3*imktg[T-3] + $AM4*imktg[T-4] + $AM5*imktg[T-5] +
$AM6*imktg[T-6] + $AM7*imktg[T-7] + $AM8*imktg[T-8]) + $B2*($AR0*ireal46[T]
+ $AR1*ireal46[T-1] + $AR2*ireal46[T-2] + $AR3*ireal46[T-3] +
$AR4*ireal46[T-4] + $AR5*ireal46[T-5] + $AR6*ireal46[T-6] +
$AR7*ireal46[T-7] + $AR8*ireal46[T-8]) if T==9 by coname: replace
`1'=$B0+$B1*($AM0*imktg[T] + $AM1*imktg[T-1] + $AM2*imktg[T-2] +
$AM3*imktg[T-3] + $AM4*imktg[T-4] + $AM5*imktg[T-5] + $AM6*imktg[T-6] +
$AM7*imktg[T-7] + $AM8*imktg[T-8] + $AM9*imktg[T-9]) + $B2*($AR0*ireal46[T]
+ $AR1*ireal46[T-1] + $AR2*ireal46[T-2] + $AR3*ireal46[T-3] +
$AR4*ireal46[T-4] + $AR5*ireal46[T-5] + $AR6*ireal46[T-6] +
$AR7*ireal46[T-7] + $AR8*ireal46[T-8] +
$AR9*ireal46[T-9]) if T>=10
end

It is an equation in sigma notation for 10 periods. The nl command line I
have written is this:

nl alpha_effects real172, variables(imktg ireal46) parameters(B0 B1 AM0 AM1
AM2 AM3 AM4 AM5 AM6 AM7 AM8 AM9 B2 AR0 AR1 AR2 AR3 AR4 AR5 AR6 AR7 AR8 AR9)
nparameters(23)

where real172 is the dependent variable. When I run this section of code, I
get a syntax error but strangely it occurs after the first iteration:

nl alpha_effects real172, variables(imktg ireal46) parameters(B0 B1 AM0 AM1
AM2 AM3 AM4 AM5 AM6 AM7 AM8 AM9 B2 AR0 AR1 AR2 AR3 AR4 AR5 AR6 AR7 AR8 AR9)
nparameters(23) (obs = 3200)

Iteration 0: invalid syntax

r(198);

end of do-file

r(198);

Any ideas as to how this error might be occuring? It seems the syntax of the
program and nl command is correct, since Stata "knows" to start the
iteration process. I just have no idea where a syntax error could be if it's
not actually in my program or nl command line.

Thanks for any help.

Terra Curtis
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index