# Re: st: User-defined MLE problem: How would you solve this?

 From efeijen@worldbank.org To statalist@hsphsun2.harvard.edu Subject Re: st: User-defined MLE problem: How would you solve this? Date Wed, 18 Jun 2008 13:08:30 -0400

```Richard, thanks that was very helpful. It seems to work!

Richard Williams
<Richard.A.Williams
.5@ND.edu>                                                      To
Sent by:                    statalist@hsphsun2.harvard.edu,
owner-statalist@hsp         statalist@hsphsun2.harvard.edu
hsun2.harvard.edu                                               cc

Subject
06/18/2008 12:59 PM         Re: st: User-defined MLE problem: How
would you solve this?

statalist@hsphsun2.
harvard.edu

At 11:32 AM 6/18/2008, efeijen@worldbank.org wrote:
>    Below you find the .ado file and the command I used for this
> problem. However
>    I know they are not correct, since my setup estimates 2 x-coefficients
>    defined by the mu1 and mu2 equations, but I only want to
> estimate one for the
>    dependent variable j: b_j. What to do such that the intercepts
> in mu1 and mu2
>    are different, but b_j are identical?
>
>    program LDV
>          version 9.2
>          args lnf mu1 mu2 sigma
>          quietly replace `lnf'=ln(1/(2*_pi*(`sigma'^2)))-(1
>          /(2*(`sigma'^2))*(\$ML_y1-`mu1'))^2 if \$ML_y1<0
>          quietly replace `lnf'=ln(1/(2*_pi*(`sigma'^2)))-(1
>          /(2*(`sigma'^2))*(\$ML_y1-`mu2'))^2 if \$ML_y1>0
>          quietly replace
>          `lnf'=ln(normalden(-`mu2',0,`sigma')-normalden(-`mu1',0,`sigma')) if
>          \$ML_y1==0
>    end
>
>
>    Stata command: ml model lf LDV (mu1:  y=x) (mu2: y=x) (sigma:)

Perhaps the constraints option would do it.  Try

constraint 1 [#1]x = [#2]x
ml model lf LDV (mu1:  y=x) (mu2: y=x) (sigma:), constraint(1)

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  Richard.A.Williams.5@ND.Edu
WWW:    http://www.nd.edu/~rwilliam

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

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