Bookmark and Share

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]

Re: st: Using maximum likelihood estimation (ml) for a nonlinear function


From   Stas Kolenikov <[email protected]>
To   [email protected]
Subject   Re: st: Using maximum likelihood estimation (ml) for a nonlinear function
Date   Sat, 12 Mar 2011 08:51:32 -0600

Emile Locque asked how range constraints can be imposed on parameters in -ml-.

There are two standard tricks (and I believe both should be described
in the [ML] book).

1. You can transform your coefficient; logistic transformation looks
an obvious choice:
args lnf lnbeta sigma
generate double beta = 1/(1+exp(-`lnbeta'))
...
end

2. Another is to return missing likelihood for bad ranges:
args lnf beta sigma
if `beta' > 0 & `beta' < 1 {
  * produce the likelihood as usual
}
else {
  replace `lnf' = .
}
end

(Note that this is probably an inferior code: `beta' is actually a
name of a variable, so you might be better off -summarize-ing it,
technically speaking.)

Either method will probably produce unstable results if you have a
unique global maximum of the likelihood in the negative range of
`beta'. The first method will want to push `lnbeta' to -infinity, and
the second method will push it to zero and complain about the missing
likelihood and being unable to compute derivatives.

BTW, in all likelihood, you copied and pasted an output from a
different model: there's some sort of delta parameter in there which
is not a part of -jprog- code.

Some other approaches you can try are given by -nl- and -gmm-. The
results should be asymptotically equivalent from all these procedures
if your error terms are normal.

On Sat, Mar 12, 2011 at 1:31 AM, Emile Locque <[email protected]> wrote:
> Hello,
>
> I want to use maximum likelihood to estimate a nonlinear equation and I do not
> come close as to how it should be programmed.
>
> My nonlinear equation is the following:
> y = [(1+x1*(1-B))/(1+x2*(1-B))]*x3 + e
> The parameter I want to estimate is B, which is present in both numerator and
> denominator and should have a value between 0 and 1.
> I assume that e (the error term) is normally distributed N(0,sigma^2).
> Both variable y and x1 are independent for each observation whereas values of
> x2
> and x3 are the same for groups of observations. (This is why I doubt whether I
> should use the lf method or one of the d methods).
> I have been thinking about splitting the equation in multiple equations to be
> estimated, but I fail to see how I can be certain that the estimated B (beta)
> is
> the same for denominator and numerator.
>
> The stata command I have tried is this one:
>
> capture program drop jprog
> program define jprog
> args lnf sigma beta
> replace
> `lnf'=-0.5*(ln(2*_pi)+ln(exp(`sigma')^2)+(y-[(1+(x1*(1-`beta’)))/(1+(x2*(1-`beta’)))]*x3)^2/exp(`sigma')^2)
>
>
>
> end
> ml model lf jprog (beta: ) (sigma: )
> ml check
> ml search
> ml maximize
>
> It returns estimation results (see below) but, not what I want to see. I do not
> know how I can program that this B (beta) is between 0 and 1.
> Nor do I know whether I am using the appropriate program. Any help is certainly
> appreciated.
>
> Iteration 5:  log likelihood =  20861.204
>
>                                                  Number of obs  =      39094
>                                                  Wald chi2(0)    =          .
> Log likelihood =  20861.204                      Prob > chi2    =          .
>
> ------------------------------------------------------------------------------
>            |      Coef.  Std. Err.      z    P>|z|    [95% Conf. Interval]
> -------------+----------------------------------------------------------------
> delta        |
>      _cons |  -1.952555  .0035763  -545.98  0.000    -1.959564  -1.945546
> -------------+----------------------------------------------------------------
> sigma        |
>      _cons |  .2865287  .0238149    12.03  0.000    .2398524    .333205
> ------------------------------------------------------------------------------
>
>
> Thanks for your consideration!
>
> E. Locque
>
>
>
>
> *
> *   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/
>



-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index