# Re: st: nl in which the nonlinear functional form is conditional on x

 From Eva Poen To statalist@hsphsun2.harvard.edu Subject Re: st: nl in which the nonlinear functional form is conditional on x Date Wed, 15 Apr 2009 00:45:17 +0100

```<>

compose a new message and send it to the list. This, among many other
useful things, is explained in the statalist FAQ.

Also, please don't post the exact same question several times (see the FAQ).

approach is, and whether or not you could reliably interpret results).
Conditioning on x is pretty much like splitting your sample in two.
Therefore you could estimate it in two parts: one for F() with - ...
if x > 0- and one for G() with - ... if x < 0-.

If you want to do it in one step, and you can write down F() and G()
such that they evaluate to zero whenever x is equal to zero, the
problem is fairly easily solved by splitting x and adding the
functions. Here is a nonsensical example.

***
sysuse auto
qui sum price
scalar mean = r(mean)
gen priceneg = ((price-mean)<0)*(price-mean)
gen pricepos = ((price-mean)>0)*(price-mean)

nl (weight = {beta}*( -sqrt(-priceneg)) + {gamma}*log(pricepos))
***

Also, I believe you could write a function evaluator program for -nl-
which implements this kind of condition; see -help nl-. But, again, I
cannot comment on the properties of the estimator under these
conditions.

Eva

2009/4/14 Quang Nguyen <quangn@gmail.com>:
> Dear All:
>
> I have the model as follows: y = F(x;  lamda) for x>0 and y= G(x:
> lamda) for x<0. Both F and G are nonlinear. Do you think we can use
> _nl_ to estimate this model? Is there a way we can write like this:
>
> nl {( y = F(x;  lamda) if  x>0 ) (y= G(x: lamda) if x<0)}
>
> Many thanks!
>
> On Tue, Apr 14, 2009 at 6:54 AM, Martin Weiss <martin.weiss1@gmx.de> wrote:
>> <>
>>
>> Rudy may also want to take a cue from the MUS book datasets at
>> http://www.stata-press.com/data/mus.html
>> File mus04p1sim.do shows how the pros use -simulate- with the -seed- set...
>>
>>
>> HTH
>> Martin

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