Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: can cond() be nested (within nl)?


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: can cond() be nested (within nl)?
Date   Mon, 3 Dec 2012 18:50:25 +0000

Same answer from me. If you have a problem, "doesn't seem to work" is
not informative. Does that mean illegal syntax or model failed to
converge? 5 parameters can be an awful lot for -nl-. My advice remains
to use -regress-.

On Mon, Dec 3, 2012 at 4:09 PM, David Raitzer <raitzer2002@yahoo.com> wrote:
> What I mean is something like this:  nl  (  y =  cond(x <={z}, cond( x <= {k},  {a}*x + {b},  {c}*x + {k}*( {a} - {c}) + {b} )   ) ,  {s}*x + {z}*( {a} - ({c}+{s})) + {b} )  , initial (a 1 b 1 c 1 k 1 s 1 z 1)
>
> However, it doesn't seem to work for me.  Is it not possible to nest cond in this manner within nl?  Thank you for your help.
>
>
> ----- Original Message -----
> From: Nick Cox <njcoxstata@gmail.com>
> To: statalist@hsphsun2.harvard.edu
> Cc:
> Sent: Monday, December 3, 2012 6:39 PM
> Subject: Re: st: can cond() be nested (within nl)?
>
> It is perfectly legal to include -cond()- within the <sexp> in
>
> nl (depvar=<sexp>) [if] [in] [weight] [, options]
>
> if that is what you mean. But -mkspline- followed by -regress- sounds
> much easier here.
>
> On Mon, Dec 3, 2012 at 9:59 AM, David Raitzer <raitzer2002@yahoo.com> wrote:
>
> I am trying to do a segmented linear regression with the nl function
> and cond.  The intention is to have two breakpoints and 3 segments,
> which means that 3 conditions are required.   Can cond be nested
> within nl to apply more than 2 conditions?  If not, what is the best
> way to approach such a regression when the segmentation depends upon 3
> ranges of an x, rather than only 2? Thanks!
*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index