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

# Re: st: Threshold regression using NL - How to specify indicator variable?

 From Nick Cox To statalist@hsphsun2.harvard.edu Subject Re: st: Threshold regression using NL - How to specify indicator variable? Date Tue, 4 Sep 2012 10:11:35 +0100

```As I understand it, your threshold c must be between 0 and 1. An
initial value for c of 10 is way outside those bounds. What the output
is telling you is that -nl- can't improve on 10, because it has tried
small changes and they didn't help at all. I would try

initial(a1 25 b1 -2 c 0.5 b2 2)

It's also true that your initial values for other parameters need to
be good guesses.

Nick

On Tue, Sep 4, 2012 at 10:02 AM, Ophelie Desmarais
> Dear George,
>
> The UCLA link was very helpful - it certainly does work that way.
>
>>> nl (y = ({a1} + {b1}*x)*(x < {c}) + ///
>>>           ({a1} + {b1}*{c} + {b2}*(x-{c}))*(x >= {c})), ///
>>>            initial(a1 25 b1 -2 c 10 b2 2)
>
> For some reason, however, I am not able to estimate the thresholds.
> The estimated coefficients for {c} and {b2} entirely depend on the
> initial values:
>
>
> Iteration 0:  residual SS =  605.2348
> Iteration 1:  residual SS =  605.2348
>
>       Source |       SS       df       MS
> -------------+------------------------------         Number of obs =      1019
>        Model |  472.843729     2  236.421864         R-squared     =    0.4386
>     Residual |  605.234846  1016  .595703588         Adj R-squared =    0.4375
> -------------+------------------------------         Root MSE      =  .7718184
>        Total |  1078.07857  1018  1.05901628         Res. dev.     =  2360.938
>
> ------------------------------------------------------------------------------
>            y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>          /a1 |   4.862555   .3162218    15.38   0.000     4.242032    5.483077
>          /b1 |   1.884921   .0682323    27.63   0.000     1.751028    2.018813
>           /c |         10          .        .       .            .           .
>          /b2 |          2          .        .       .            .           .
>          /a2 |   .0607663   .0084165     7.22   0.000     .0442505    .0772821
> ------------------------------------------------------------------------------
>
> But I am able to replicate this using another independent variable -
> but I have no clue why this is behaving weird for the independent
> variable I intended to use. The independent variable lies between 0
> and 1, has mean 0.49 and stdev 0.38. Should there be any particular
> reason why the values depend so much on the initial ones?
>
> Thanks a lot,
>
> O
>
> On 4 September 2012 08:01, Maarten Buis <maartenlbuis@gmail.com> wrote:
>> On Tue, Sep 4, 2012 at 1:30 AM, Hoffman, George wrote:
>>> Have you looked at
>>> http://www.ats.ucla.edu/stat/stata/faq/nl_optimal_knots.htm
>>>
>>> the general form is explained about half way done the page.
>>>
>
>>
>> An alternative specification is discussed here:
>> <http://www.stata.com/statalist/archive/2008-01/msg01006.html>
>>
>> -- Maarten
>>
>> ---------------------------------
>> Maarten L. Buis
>> WZB
>> Reichpietschufer 50
>> 10785 Berlin
>> 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/
*
*   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/
```