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.

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

From |
"Hoffman, George" <ghoffman@mcw.edu> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: Threshold regression using NL - How to specify indicator variable? |

Date |
Mon, 3 Sep 2012 23:30:21 +0000 |

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. nl (y = ({a1} + {b1}*x)*(x < {c}) + /// ({a1} + {b1}*{c} + {b2}*(x-{c}))*(x >= {c})), /// initial(a1 25 b1 -2 c 10 b2 2) also, look at 'nlhockey', a user-written package that does hockey-stick regression as an add-on to nl. (findit nlhockey) Both approaches work! Start with nlhockey. -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: Monday, September 03, 2012 1:57 PM To: statalist@hsphsun2.harvard.edu Subject: Re: st: Threshold regression using NL - How to specify indicator variable? What do you mean by "doesn't work"? An alternative is to use -cond(,)-. On Mon, Sep 3, 2012 at 7:46 PM, Ophelie Desmarais <ophelie.desmarais@googlemail.com> wrote: > Dear Nick, > > Thanks again for your fast reply and help. > > I have tried it the way you suggested, but it doesn't work - would you > mind giving me a hint on how the actual expression would look like? > > nl (y = {a1=1}+{a2=1}*X*(X>{Z=1})+{a3=1}*X*(X<{Z=1})) ? > > Thank you so much. > > Ophelie > > On 3 September 2012 19:26, Nick Cox <njcoxstata@gmail.com> wrote: >> You don't need an explicit operator or function for indicators. (X < >> Z) is perfectly legitimate Stata code and such terms can be included >> freely in defining models to -nl-. Drop the I's from your expression >> and you are half-way there. >> >> Nick >> >> On Mon, Sep 3, 2012 at 7:03 PM, Ophelie Desmarais >> <ophelie.desmarais@googlemail.com> wrote: >> >>> I would like to create a simple non-linear threshold regression: >>> >>> y = a1+a2*X*I(X>Z)+a3*X*I(X<Z) >>> >>> where in the linear case a2=a3. Z is unknown and to be estimated. >>> >>> Is there anyway to do this with Stata's "nl" command? The tutorial >>> suggests that you can run relatively straightforward models like: >>> nl (y = {b0=1}*(1 - exp(-1*{b1=0.1}*x))) >>> >>> i.e. you just define the functional form in command line. But I am >>> not aware of an operator for an indicator variable, so I'm not sure >>> how to do this here. >>> >>> Any suggestions would be appreciated - I did check the previous >>> posts and run a Google search, but no success. >> * >> * 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/ * * 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/

**Follow-Ups**:**Re: st: Threshold regression using NL - How to specify indicator variable?***From:*Maarten Buis <maartenlbuis@gmail.com>

**References**:**st: Threshold regression using NL - How to specify indicator variable?***From:*Ophelie Desmarais <ophelie.desmarais@googlemail.com>

**Re: st: Threshold regression using NL - How to specify indicator variable?***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: Threshold regression using NL - How to specify indicator variable?***From:*Ophelie Desmarais <ophelie.desmarais@googlemail.com>

**Re: st: Threshold regression using NL - How to specify indicator variable?***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: st: Rolling correlation coefficients with panel data** - Next by Date:
**st: Boxplots - avoiding the box in a strata with a small number of observations** - Previous by thread:
**Re: st: Threshold regression using NL - How to specify indicator variable?** - Next by thread:
**Re: st: Threshold regression using NL - How to specify indicator variable?** - Index(es):