Announcement

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

  • Why does my custom tobit not converge?

    I am learning ml and wrote a simple tobit following the likelihood formula from here: https://jdemeritt.weebly.com/uploads...764/tobit1.pdf
    Click image for larger version

Name:	Capture_he.PNG
Views:	1
Size:	19.4 KB
ID:	1708743




    Sorry, wrong title! It does converge but give different parameter estimates

    Here is an MWE

    Code:
    
    // Make data
    
    set seed 12553
    clear
    set obs 10000
    gen y = runiformint(0,10)
    gen x = runiformint(0,1)
    gen z = abs(rnormal() * 50)
    
    
    // Lower censoring
    
    gen Di = (y!=0)
    
    cap program drop mytobit_gf0
    program mytobit_gf0
        args todo b lnfj
        tempvar xb sigma non_censored censored
        
        qui gen double `xb' = (`b'[1,1]*x + `b'[1,2]*z + `b'[1,3])
        qui gen double `sigma' = `b'[1,4]
        
        qui gen double `non_censored' = Di * (-ln(`sigma') + ln(normalden((y-`xb')/`sigma')))
        qui gen double `censored' = (1-Di) * (1 - normal(`xb'/`sigma'))
        
        qui replace `lnfj' = `non_censored' + `censored'                    
    end
    
    ml model gf0 mytobit_gf0 (y = x z) /sigma        
    ml check    
    ml search                    
    ml maximize, difficult
    
    tobit y x z, ll(0)
    Last edited by Henry Strawforrd; 06 Apr 2023, 06:17.

  • #2
    It does actually give the same results after fixing a typo!

    Comment

    Working...
    X