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

st: Syntax Problem in Nonlinear Regression


From   "Dale W. Larson" <DWL@larsonglobal.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Syntax Problem in Nonlinear Regression
Date   Fri, 26 Sep 2003 16:28:41 -0400

Hi,

I am having trouble defining the estimating equation for a nonlinear regression
in the fcn program.  I am using Version 7.

In a string of variables and coefficients of the form (varname*$B#), the
program stops at one with the error message:

"varname* invalid name"

In other words, it thinks the * is a part of the varname, rather than an
operator. 

I tried putting the varname in parentheses, to distinguish it from the
operator, but then I get the error message, "Unknown function ()".

Here is the exact expression from my do-file: 
((kuwait90*$B8)+(kuwait91*$B9)+(kuwait92*$B10)+(bothgcc*$B11))

The regression ran okay until I added the (bothgcc*$B11).  Can anyone see what
I am doing wrong?

FYI, the command, summarize bothgcc, works fine, i.e., for this command it
recognizes "bothgcc" as a variable.

Below is my entire do-file.

Dale
----------------------------------------------------------------------------
-----
use Dataset4, clear
program define nlnonlinear
version 7.0
if "`1'"=="?" {
#delimit ;
global S_1 "B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11";
#delimit cr
*
global B1=.8
global B2=.8
global B3=-.2
global B4=-.2
*
global B5=-1
global B6=-1
*
global B7=-1
*
global B8=-1
global B9=-1
global B10=-1
*
*global B11=1
exit
*X1 is real GDP of importing country
*X2 is real GDP of exporting country
*X3 is the population of the importing country
*X4 is the population of the exporting country
*
*X5 is the tariff of the importing country
*X6 is the MFN tariff of the exporting country
*
*X7 is distance between capital cities
*
*X8 is a dummy variable=1 when trade involved Kuwait in 1990
*X9 is a dummy variable=1 when involved Kuwait in 1991
*X10 is a dummy variable=1 when trade involved Kuwait in 1992
*
*X11 is a dummy variable=1 when both countries are members of GCC
}
#delimit ;
replace `1'= (crealgdpm^$B1)*(crealgdpx^$B2)*(popm^$B3)*(popx^$B4)
*(tm^-1)*(tx^$B6)
*(odistance^$B7)
*e^((kuwait90*$B8)+(kuwait91*$B9)+(kuwait92*$B10)+(bothgcc*$B11));
#delimit cr
end
*End of program.  Ready to do nonlinear regression.
set more off
nl nonlinear averagem1


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