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

# Re: st: non linear equation difficulties with nl function evaluation program

 From Carolina Lopez To statalist@hsphsun2.harvard.edu Subject Re: st: non linear equation difficulties with nl function evaluation program Date Wed, 25 Aug 2010 09:36:40 +0200

```Hi Maarten,

The thing is that n is the number of cities were the operator is
present using the same type of contract, so it varies by city and
year.

I already calculated this, and introduced it in the data as a
variable, to then simplify estimations.

I need it to be taken as a variable.

Thanks
Caorlina

2010/8/25 Maarten buis <maartenbuis@yahoo.co.uk>:
> --- On Tue, 24/8/10, Carolina Lopez wrote:
>> I am working on the estimation of this transport cost
>> function, and getting issues with the func prog using nl:
>> lcostratio= { [a(1+a+(n-2))] / [(1+a-k)(1+a+k(n-1)] } {
>> b1lpko+b2lsalratio} - { [ak] / [ 1+a-k)(1+a+k(n-1)] }
>> { b3sum_lpko + b4sum_lsalratio  } + { [1+(n-1)k ] /
>> [ [ 1+a+k(n-1)]} lna
>
> <snip>
>
>> I am not sure I am introducing n correctly here, since I do
>> not expect a parameter, I just want it to feed data for my
>> terms.
>
> I guess n is just the number of observations, you can access
> that using _N, if you have missing values I would outside
> the evaluator progam do something like
>
> count if !missing(var1, var2, ...)
> global S_N = r(N)
>
> And than inside the evaluator program refer to n as \$S_N.
>
> In general, the way to debug such a program is to simplify,
> start with a very simple version of that function, get that
> to work, add a parameter, get that to work, etc, etc.
>
> Hope this helps,
> Maarten
>
> --------------------------
> Maarten L. Buis
> Institut fuer Soziologie
> Universitaet Tuebingen
> Wilhelmstrasse 36
> 72074 Tuebingen
> Germany
>
> http://www.maartenbuis.nl
> --------------------------
>
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```