Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

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

From |
Nick Cox <n.j.cox@durham.ac.uk> |

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

Subject |
st: RE: Curve fitting with nl log4, how to put constraints on parameters |

Date |
Mon, 14 Nov 2011 17:46:37 +0000 |

If something must be positive, its logarithm can still be negative. So exp(log(positive)) will always be positive. See http://www.stata.com/support/faqs/stat/interval-constraints.html Whether imposing a constraint is valid is more complicated question. There are two opposite truths, which are both correct. 1. If a model is appropriate, you should not need to force it. Constraints that are natural will be obeyed automatically. 2. Allowing impossible parameter values in model fitting is just silly. You should specify the rules for your model fit as an expression of what makes sense (and of what does not). Nick n.j.cox@durham.ac.uk Jennyfer Wolf I am trying to do curve fitting for survey estimates over time with the nl:log4... command (y = b0 + b1/(1 + exp(-b2*(x-b3))). This logistic function seems to me to be the most realistic shape to describe the data. However, in some cases (e.g. when I only have survey estimates that are quite linear over time but the last estimate is going a bit down) I would need to constraint b2 that it cannot become negative (if not I get a curve which is strongly declining which is very unlikely to be true and is not supported by my data). I wrote the formula (instead of log4) so I could try to get only positive values for b2 with for example "invlogit({lnb2}) 1. Would this be a valid thing to do? However, when I try the two commands which I thought should give me the same results: nl log4:[VARNAME] [VARNAME] if country=="maldives" and nl ([VARNAME]={b0}+{b1}/(1+exp(-{ b2}*([VARNAME]-{b3}))) if country=="maldives") I get different estimates (e.g. if I use the second formula I only get a value for b0). 2. Could you give me advise on how to do curve fitting by using this function with the constraint that the b2 does not get negative? * * 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/

**References**:**st: Curve fitting with nl log4, how to put constraints on parameters***From:*Jennyfer Wolf <jennyfer.wolf@googlemail.com>

- Prev by Date:
**st: FW: Standard error estimates lincom vs. estimates from predict command** - Next by Date:
**st: a model that runs in LISREL, but not in Stata 12. Any suggestions?** - Previous by thread:
**st: Curve fitting with nl log4, how to put constraints on parameters** - Next by thread:
**st: simulating random numbers from zero inflated negative binomial estimates** - Index(es):