StataCorp has a helpful FAQ, How do I fit a linear regression with interval (inequality) constraints in Stata? . I've used that reference to fit a *nonlinear* model using nl. (It also links to a page on nonlinear constrained models using ml - more on that later.)
The page recommends using functions to apply inequality constraints. For example, to constrain a parameter to be above zero, code exp(lnb)*somevar rather than b*somevar. Then recover b in post-estimation.
This usually works. But sometimes it results in convergence to a globally nonoptimal solution (inferior on an AIC or BIC basis - see the command estat ic). This problem may not be obvious. There are 3 possible fixes:
a) Muck around with the optimization procedure. There's limited scope for this option in nl though unlike, say, arima.
b) Muck around with seeding. This hasn't always worked for me.
c) Reverse out of whatever function you are using with nesting: exp(ln(b))*somevar. b will stay positive by necessity.
I've had good luck with option c) and exp(ln(b)) over the years. Not perfect luck, but very good luck. Today I had similar success with using logit(invlogit(b)), rather than invlogit(b). The latter led to globally non-optimal coefficients, even with good seeds and pretty small stepsizes specified (i.e. delta(4e-10), where the default is delta(4e-7)). So I would recommend reversing out of whatever constraining function you use, so as not to confuse the optimization algorithm. FWIW.
I'm not convinced this would be a problem if I was using linear estimation. And perhaps I should be using ml - that's what the above webpage recommends for handling convergence issues (assuming you are aware of them). The reasons I don't are a) I'm not familiar with ml and moreover b) I'm assuming log normal errors, which are handled well with a straightforward transformation of my equation in nl. I think. Comments are welcome.
Related Posts with nl with inequality constraints lead to bad local optima, with fix
Logit Regression Model / Plotting InteractionsHi everyone, I am working at my final paper and need some guidance. I want to look at the party id…
Dummy variable for neonatal Mortality, Infant mortality and Child mortalityHi, I am working on the Demographic health survey (DHS) data. I have to compute the neonatal Mortali…
-margins- after -xtlogit,fe-Dear Statalist This is a question about interpreting the results from a panel data fixed-effects lo…
Loop over multiple arrays via foreachHello together! trying now since a few hours to fix my problem - I am not able to come up with an a…
ICD 10 to ICD-9 mapping using GEMsHi stata users, anybody has any experience in using GEMs files to map backwards from icd10 to ICD10 …
Subscribe to:
Post Comments (Atom)
0 Response to nl with inequality constraints lead to bad local optima, with fix
Post a Comment