There are a few problems:
1. To call program, it should be -nlsal spe hpe- not -nl sal: spe hpe-
2. The -if- option should be in brackets.
3. You are not actually calling -nl- Do you mean something like this:
program nlsal, rclass
syntax varlist(min = 2 max =2) [if]
tokenize `varlist' `if'
reg `1' `2'
local a = _b[_cons]
local b = _b[`2']
nl (`1'= {alpha=`a'} + {beta=`b'}*`2'^{gamma=1} ) `if', nolog
return local title "`1' = alpha+beta*`2'^gamma"
end
Scott
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of clothilde dufort
> Sent: Monday, August 22, 2005 10:05 AM
> To: [email protected]
> Subject: st: nonlinear least square
>
> hi,
>
> I am trying to estimate the follwing non linear
> equation :
>
> spe=alpha + beta*hpe^gamma
>
> so I use the function "nl" in stata and before I write
> the following program.
>
> ---
>
> program nlsal, rclass
>
> syntax varlist(min=2 max=2) [aw fw iw] if
>
> local lhs: word 1 of `varlist'
>
> local rhs: word 2 of `varlist'
>
> regress `lhs' `rhs' [`weight'`exp'] `if'
>
> tempname a b
>
> scalar `a' = _b[_cons]
>
> scalar `b' = _b[`rhs']
>
> return local eq "`lhs' =
> {alpha=`=`a''}+{beta=`=`b''}*`rhs'^{gamma=1}"
>
> return local title "`lhs' = alpha+beta*`rhs'^gamma"
>
> end
>
> ---
>
> and then i write :
>
> nl sal: spe hpe
>
> but stata reply :
>
> : invalid name
> nlsal: refused query, rc=198
>
> I really don't see what's wrong with my program. If
> anybody has an idea, please...
>
> clothilde
>
>
>
>
>
>
> __________________________________________________________________________
> _
> Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
> T�l�chargez cette version sur http://fr.messenger.yahoo.com
> *
> * 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/