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

# st: 回复： st: Re: st: 回复： st: error report with ml check

 From 健 张 To "statalist@hsphsun2.harvard.edu" Subject st: 回复： st: Re: st: 回复： st: error report with ml check Date Sat, 17 Sep 2011 03:38:55 +0800 (CST)

```Hi, Maarten:
Thank you for your reply. I have read the bipp_lf.ado. It is really quite different from what I wrote. Right now, I am just working on the simplest case, the linear restriction case.

The code for the linear restriction case is like this:
program define bipp_lf
version 6.0
local ll    "`1'"  /* Log l */
local xb1   "`2'"  /* x1*b1 */
local xb2   "`3'"  /* x2*b2 */
local kappa "`4'"  /* atanh(rho)   */

local rr = (exp(2*`kappa')-1) / (exp(2*`kappa')+1)

if `kappa' < -18 { local rr = -1 }
if `kappa' >  18 { local rr =  1 }

quietly {
replace `ll' = binorm(`xb1',`xb2',`rr')
replace `ll' = 1-`ll' if \$ML_y1 == 0
replace `ll' = log(`ll')
}
end

I have several questions regarding the code:
What does those "`1'" , "`2'" , "`3'" , "`4'"  stand for? I can understand the explaining part behind them. However, I dont see where you use those 1,2,3,4.  Why do you need to generate kappa? Why do you use the function atanh(.) to generage kappa? For rr, did you parameterized kappa so that the range can be (-infinity, infinity), which is as the technique note on P56 of Maximum Likelihood Estimation in Stata, Gould, Pitblado and Sribney, Stata Press: 3d ed., 2006? If not, why do you generate rr? Where do 18 and -18 come from?
I am sorry that I ask so many questions. I really dont know much about ml command and how to write code by myself.
Thank you sooooooo much!!

Best,
Jian

----- 原邮件 -----

On Thu, Sep 15, 2011 at 10:18 PM, å¥ å¼  <victerzj2@yahoo.com.cn> wrote:
>The likelihood evaluator I wrote is like this:
> program mybiprobit2_lf
>  version 9.1
>  args lnf xb zc rho
>  quietly replace `lnf' = ln(binormal( `xb',`zc', `rho')) if \$ML_y1 == 1
>  quietly replace `lnf' = ln(binormal(-(`xb',`zc', `rho'))) if \$ML_y1 == 0
> end
> This code is simply mimicing the code for probit case. The probit case is like this
> program myprobit_lf
>  version 9.1
>  args lnf xb
>  quietly replace `lnf' = ln(normal( `xb')) if \$ML_y1 == 1
>  quietly replace `lnf' = ln(normal(-`xb')) if \$ML_y1 == 0
> end
>
> Therefore, I dont quite understand why the negative sign should be removed.

That is  for many reasons not the correct generalization of the probit
likelihood to the biprobit likelihood. You can see a correct
implementation of the likelihood function by typing in Stata

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------

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

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