Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • mlexp for ordered probit with Heckman selection

    Hi,

    I'm trying to use mlexp to replicate the results obtained with the command heckoprobit.
    I was able to use mlexp and to replicate the results obtained with the command oprobit and goprobit but I'm struggling in adding the selection.

    Here is my code:

    Code:
    * Oprobit by hand
    
    clear
    set obs 200
    
    set seed 1
    gen yy=1 if _n>=20
    replace yy=2 if _n>=20 & _n<=50 
    replace yy=3 if  _n>=150
    
    
    gen y=100*rnormal()
    gen s=(_n>=180)
    replace y=. if s==0
    
    gen x=30*rnormal()
    replace x=x+3 if _n>=150
    su
    
    gen y1=(yy==1)
    gen y2=(yy==2)
    gen y3=(yy==3)
    
    mlexp (ln(normal(-{b1}*x+{mu1}))*y1+ln(normal(-{b1}*x+{mu2})-normal(-{b1}*x+{mu1}))*y2+ln(1-normal( -{b1}*x+{mu2}))*y3), from(b1=0.02 mu1=0.03 mu2=0.05)
    oprobit yy x
    
    *Goprobit by hand
    
    mlexp (ln(normal(-{b1}*x+{mu1}))*y1+ln(normal(-{b2}*x+{mu2})-normal(-{b1}*x+{mu1}))*y2+ln(1-normal( -{b2}*x+{mu2}))*y3), from(b1=0.002 mu1=0.03 mu2=0.5)
    
    goprobit yy x
    Can anyone help me out with this?

    Thank you very much!

  • #2
    Ordered probit with selection is actually a fairly difficult log likelihood function that requires integrating the ordered probit probabilities over the unobserved error in the selection equation. I wouldn't be able to do it even given a lot of time (but then I'm a pretty low-level Stata coder).

    Comment


    • #3
      Dear Laura: If you were not aware of this, you may read the code of heckoprobit by writing "viewsource heckoprobit.ado" in the command window.

      It looks as if the code utilises both oprobit and probit, and (perhaps) the full model is found in the line "noi ml model lf2 heckop_lf2()"

      Comment

      Working...
      X