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

st: Re: old nl prolem still there

From (Roberto G. Gutierrez, StataCorp.)
Subject   st: Re: old nl prolem still there
Date   Sat, 12 Oct 2002 13:27:33 -0500

Alan Feiveson <> asks:

> Some time ago I noticed that when running -nl- with an "if"condition, that
> condition is ignored when intitializing the parameter estimates in the first
> part of the program. Apparently this is still the case- here's an example:

> program define nlt4
> args q a x 

> if "`1'" == "?" {
>    global S_1 " A V M X0"
>    summ `x' [w=`a'],det
>    global X0=r(mean)
>    global A=r(sd)
>    global V = 1
>    global M = 1
>    exit
>    }


If you use

   . summ `x' [w=`a'] if e(sample), det

your if condition will get respected when setting initital values.  -nl-, even
before setting the initial values, makes an even earlier dry run through your
program and sets e() results such as e(sample), e(wexp), e(wtype), and
e(depvar), so that you can refer to these in later calls to your program.

This is documented in the "More on nlfcns" section of [R] nl.

The fact that this is not done automatically is not a bug, however. There
exist cases where you may want access to more data than merely the estimation
sample in your -nl- program.

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index