[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: boundary constraints within nl

From   "E. Paul Wileyto" <>
Subject   Re: st: boundary constraints within nl
Date   Fri, 06 Jun 2008 13:36:24 -0400

I'm pasting in the same response I put in last time for the same sort of question. The strategy is this... assume that Stata will fit a parameter going from minus infinity to plus infinity. You sustitute a form directly in place of that parameter that takes an unbounded input, and places bounds on it.

In your case it is simple... just exponentiate:

nl (y = ({a}+{b}* x) * (1-x))


nl (y = (exp({a})+exp({b})* x) * (1-x))

The estimates for a and b will actually be the logs of the parameters of interest. After the estimate, use -nlcom- to retrieve your parameters and standard errors.


Here's the last email on the same subject...

An easy way to impose b>0 is to substitute b=exp(c). c is unconstrained, and would have a range from minus to plus infinity, but b would be greated than 0.

Likewise, for k substitute k=((k2-k1)/(1+exp(m))+k1. m is unconstrained, but k would fall between k1 and k2.
I use these tricks all the time and they work very well. To get back estimates and standard errors for b and k, use nlcom.


Olga Lyashevska wrote:
Dear all,

We have a negative exponential growth model.
y=a exp(-kx)+b
Is there is a way to impose constrains on model parameters such as b>0 and

Thank you in advance,

Marc Keuschnigg wrote:

I am estimating non linear least squares models (nl) using equations like: nl (y = ({a}+{b}* x) * (1-x)).
My question is, how do I impose parameter restrictions like a >=0 and b >=0?
I could log-transform the parameters, but I don't know how to do it technically within the nl command.

Thanks for helping,

* For searches and help try:

E. Paul Wileyto, Ph.D.
Assistant Professor of Biostatistics
Tobacco Use Research Center
School of Medicine, U. of Pennsylvania
3535 Market Street, Suite 4100
Philadelphia, PA 19104-3309

Fax: 215-746-7140
* For searches and help try:

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