# RE: st: Non-linear MLE programming + inequality constraints

 From "Nick Cox" To Subject RE: st: Non-linear MLE programming + inequality constraints Date Thu, 1 Feb 2007 11:00:37 -0000

```There are various further takes. Here I am dredging my memory
the econometric literature on fitting production functions
when working out how best to fit power functions to environmental
data. The economics was irrelevant, as the algebra was the same.
My impression is that production functions, modelled as the
product of power terms, don't have a vast amount of theory behind them:
they are just convenient forms that seem qualitatively right for the
kinds of monotonic behaviours that might occur. "Cobb-Douglas" may
be one of those incantations handed down from generation to generation,
obscuring the fact that power functions are not a very big deal
(and sometimes wrong, as when there are lower or upper limits in
operation).

Firms with a zero for a covariate are contradicting the
model. If the model is correct, they shouldn't be in business.
So you have to decide which you believe more, the data or the
model.

You might decide to exclude those firms from the data fitted.
They are just not suitable for fitting this model.

You might decide that the zeros cannot really be zeros, but
represent some measurement problem. If so, one tactic is
to map the zeros to missings and try imputing the missings
on the basis of the other covariates. Otherwise, you might
fudge the zeros to some small nonzero amount. However, that is
unattractive as such data points may have a lot of leverage,
whatever you do, particularly once you transform.

In fact, none of these takes is especially attractive....

Nick
n.j.cox@durham.ac.uk

Maarten buis

> There is no command in Stata that enables you to use an inequality
> constraint. There are tricks you can use. For instance: A
> variance must
> be larger then zero, so instead of maximizing the variance you can
> maximize the ln(variance), a proportion must remain between zero and
> one, so instead of maximizing the proportion one can maximize
> the logit
> of the proportion, a correlation must stay between -1 and 1 so instead
> of maximizing the correlation one can maximize the Fisher Z
> transformed
> correlation.
>
> However, Nick just explained that you do not need to do that, and I
> agree. Adding some constant to a variable so that the log doesn't
> become zero is making an error, maybe or maybe not a necessary error
> but still an error, why do you expect your data to be able to inform

aslihan arslan

> > Thanks for those who responded to my previous
> > question.
> > I have an updated question about the non-linear ML
> > programming and constraints:
> >
> > Is there way of introducing inequality constraints for
> > the *parameters* defined by "args" at the beginning of
> > an ml program?

n j cox <n.j.cox@durham.ac.uk> wrote:
> >
> > > I don't think anyone needs to look at your code,
> > > as at least one major problem is evident in
> > >
> > > You say you are using a constraint like
> > >
> > > constraint 1 `alpha'>0
> > >
> > > Here I take your "like" literally. It so happens
> > > that -constraint- doesn't complain if you specify
> > > a constraint in this way -- even if you have not
> > > specified a local macro called alpha -- but that
> > > absence of bad news is not good news.
> > >
> > > First, your constraint is an inequality and as such
> > > not linear and thus outwith the reach of
> > > -constraint-.
> > > Perhaps -constraint- is a bad name and it really
> > > should be
> > > -linearconstraint- but that would get no votes in
> > > the
> > > Statavision Name Contest. No matter: it is plainly
> > > laid out in the help that -constraint- deals with
> > > linear
> > > constraints (and none other).
> > >
> > > Second, although your constraint won't do, it is
> > > also
> > > wrong for another reason. Constraints take their
> > > identities
> > > from variable names and possibly equations, and
> > > -constraint-
> > > can't work with names that happen to be your private
> > > names
> > > for parameters, even if those names are used inside
> > > your
> > > program. (You certainly can't expect -constraint- to
> > > look
> > > inside your program!)
> > >
> > > So far, all negative.
> > >
> > > I would forget about the constraint. If your
> > > specification
> > > is sensible a positive value for alpha will emerge
> > > from the
> > > estimation. If it doesn't you have a signal that the
> > > apecification
> > > is suspect in that regard.
> > >
> > > Alternatively, just try log(x + 1). The extra degree
> > > of freedom
> > > might come in handy. I used to think log(x + 1) was
> > > a fudge but
> > > I now regard it more fondly. It's a function that
> > > goes to 0 as x goes
> > > to 0 from above and it behaves like log x as x gets
> > > very large,
> > > so it is fairly well motivated.
> > >
> > > Nick
> > > n.j.cox@durham.ac.uk
> > >
> > > aslihan arslan
> > >
> > > I am trying to program an ML model to estimate Log
> > > Cobb Douglas production function where some rhs
> > > variables have zero values. To make logs defined I
> > > am
> > > adding a constant to variables with zeros that needs
> > > to be estimated too (hence nonlinear MLE).  The
> > > function looks like:
> > >
> > > lnY=B0+B1*lnX1+B2*ln (X2+alpha)+epsilon
> > >
> > > where X2 is the variable with some zero values, and
> > > B0, B1, B2 and alpha need to be estimated. I am also
> > > using a constraint like:
> > > constraint 1 `alpha'>0.
> > >
> > > My program does not work and I am wondering whether
> > > anybody can help me with this program. I did not
> > > paste
> > > the whole program here since it is a little long,
> > > but
> > > can send it to those who could help.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```