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

# st: RE: Maximum Likelihood

 From Timothy Mak <[email protected]> To "[email protected]" <[email protected]> Subject st: RE: Maximum Likelihood Date Wed, 2 Apr 2014 17:41:24 +0800

```Hi,

I see a number of strange codings in your codes below:

1. I did "search normprob" and "search binorm". Apparently, Stata doesn't have these functions. I suspect this is what Stata is complaining. Perhaps you want "binormal()" and "normal()" instead??? Try typing

help functions

to see what are acceptable Stata functions

2. Try not to use too many ^ if you can. E.g. ln(x^y) = y*ln(x). e.g. if you type,

di ln(10^1000)

you get a missing, but if you type

di 1000 * ln(10)

that's ok.

That's all I can spot now.

Tim

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hitomi Amaya
Sent: 02 April 2014 02:53
To: [email protected]
Subject: st: Maximum Likelihood

Hello,

I defined the following maximum likelihood program for bivariate probit
model.
STATA gave me an error "unknown function 1-()".
I found William Gould of Stata corp mentioning:
"Never code 1-normprob(z).  Code instead normprob(-z), which is far more
accurate."
to Deborah who raised a similar question on this STATA list.

However, as you can see in my code below, I have 1-(normprob(z)^131) instead
of 1-normprob(z).
I cannot easily convert it into a form without using 1-(...).

I read "Maximum Likelihood Estimation with Stata", but I couldn't find a
solution.
I would very much appreciate it if anyone could come up with a solution to
this problem.

There is my code (which is a modification of the code written by Antoine,
also found on the STATA list):

program define mybiprobt
args lnf theta1 theta2 theta3
tempvar TH
quietly gen double
`TH'=((exp(`theta3')-exp(-`theta3'))/(exp(`theta3')+exp(-`theta3')))
quietly replace
`lnf'=(ln(binorm(-`theta1',-`theta2',`TH'))-ln((1–(normprob(-‘theta2'))^131)^(1/48)))
if \$ML_y1==0 & \$ML_y2==0
quietly replace
`lnf'=(ln(binorm(-`theta1',`theta2',-`TH'))-ln((1–(normprob(-‘theta2'))^131)^(1/48)))
if \$ML_y1==0 & \$ML_y2==1
quietly replace
`lnf'=(ln(binorm(`theta1',-`theta2',-`TH'))-ln((1–(normprob(-‘theta2'))^131)^(1/48)))
if \$ML_y1==1 & \$ML_y2==0
quietly replace
`lnf'=(ln(normprob(`theta2')-binorm(-`theta1',`theta2',-`TH'))-ln((1–(normprob(-‘theta2'))^131)^(1/48)))
if \$ML_y1==1 & \$ML_y2==1
end

Thank you.
Hitomi Amaya

--
View this message in context: http://statalist.1588530.n2.nabble.com/Maximum-Likelihood-tp7580502.html
Sent from the Statalist mailing list archive at Nabble.com.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```