[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From   Eva Poen <>
Subject   Re: st: nl in which the nonlinear functional form is conditional on x
Date   Wed, 15 Apr 2009 00:45:17 +0100


Please don't reply to a previous message with a new question. Instead,
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).

Concerning your question:
Others will know more about this (especially how appropriate this
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


2009/4/14 Quang Nguyen <>:
> 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 <> wrote:
>> <>
>> Rudy may also want to take a cue from the MUS book datasets at
>> File shows how the pros use -simulate- with the -seed- set...
>> HTH
>> Martin

*   For searches and help try:

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