 Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: Nonlinear regression syntax

 From Nick Cox To statalist@hsphsun2.harvard.edu Subject Re: st: Nonlinear regression syntax Date Sat, 19 Jan 2013 13:19:16 +0000

```You have

{rg*(1+exp(-gamma*(moveave-ci)))^-1}

That will make no sense to -nl-. The most basic syntax for braces { }
is that braces must enclose parameter names only. There are other
possibilities but they do not cover your syntax.

{rg}*(1+exp(-gamma*(moveave-ci)))^-1

would make sense if and only if the names

gamma
moveave
ci

are names of variables (or possibly names of known scalars).

You need to tell us what your model is, distinguishing variables,
known scalars if any and parameters to be estimated.

Nick

On Sat, Jan 19, 2013 at 12:39 PM, David Ashcraft
<ashcraftd@rocketmail.com> wrote:

> rg, algebraic expression and gfc are parameters to be estimated and that's why I used braces {}. gamma and ci are constants. in the first line: rg and moveave are variables where moveave is the quarterly moving average of rg.
>
> You mentioned that a brace is omitted. I do not see the omitted brace. Can you please point out the missing brace in the following?
>
> nl (rx={rg}+{rg*(1+exp(-gamma*(moveave-ci)))^-1}+{gfc})

Nick Cox <njcoxstata@gmail.com>

> Did you type _exactly_ the first line? If "rg" is a parameter to be
> estimated, then a brace "}" has been omitted. Is "gamma" really a
> variable as implied by your syntax?
>
> In general, there seems confusion here over algebraic conventions and
> Stata rules. In algebra you can use braces { } using similar rules to
> parentheses () and brackets []: i.e. they are all delimiters and must
> just match and nest logically. But in -nl- expressions braces {} have
> a special meaning to indicate parameters to be estimated and makes no
> sense otherwise.
>
> Nick
>
> On Sat, Jan 19, 2013 at 11:12 AM, David Ashcraft
> <ashcraftd@rocketmail.com> wrote:
>> I want to run the following model as a non-linear regression:
>>
>> nl (rx={rg}+{rg*(1+exp(-gamma*(moveave-ci)))^-1}+{gfc})
>>
>> where rx is dependent variable. when I run this model Stata gives the  error code: r(480); starting values invalid or some RHS variables have missing values
>>
>>
>> As a second option, I solved the non-linear function outside the equation by having a new variable fm={rg*(1+exp(-gamma*(moveave-ci)))^-1} and run again:
>>
>> nl (rx={rg}+{fm}+{gfc})
>>
>> Now I get the results with omitted values for fm.
>>
>> I don't know where is my mistake. Any help will be greatly appreciated.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```