I wrote my own function to fit a Tobit model, but it only works when censoring from below, not above (or both). I can't figure out why.
Suppose you have data censored from above at 1 and below at 0:
Here is the canned estimation:
and here is my take:
The bold line in the above chunk is the likelihood for censored observations. If I change that to capture left-censored observations, I get identical results as
. But it doesn't work for right-censored observations. What is going on?
Here are the full results:
Suppose you have data censored from above at 1 and below at 0:
Code:
sysuse auto, clear version 15 set more off // generate fake data: lower limit is zero, upper limit is one gen y =invnormal(runiform()) replace y = 0 if y < 0 replace y = 1 if y > 1
Code:
qui tobit y length turn headroom, ul(1) eststo m1_1
Code:
capture program drop mytobit_lc program mytobit_lc args lnf beta sigma tempvar lnlj quietly { gen double `lnlj' = log(1-normal(`beta'/`sigma')) if $ML_y1==1 replace `lnlj' = log((1/`sigma')*normalden(($ML_y1-`beta')/`sigma')) if $ML_y1>0 replace `lnf' = `lnlj' } end ml model lf mytobit_lc (y = length turn headroom) /sigma qui ml maximize eststo m1_2
Code:
qui tobit y length turn headroom, ll(0)
Here are the full results:
Code:
. esttab m1_1 m1_2 m2_1 m2_2, mtitles("canned LC" "user LC" "canned RC" "user RC") ---------------------------------------------------------------------------- (1) (2) (3) (4) canned LC user LC canned RC user RC ---------------------------------------------------------------------------- main length -0.00107 -0.00107 0.00203 -0.00265 (-0.13) (-0.13) (0.42) (-0.81) turn -0.00137 -0.00137 -0.0126 0.0116 (-0.04) (-0.04) (-0.54) (0.73) headroom -0.00454 -0.00454 -0.0203 0.0287 (-0.04) (-0.04) (-0.29) (0.61) _cons 0.286 0.286 0.494 0.0838 (0.35) (0.35) (1.07) (0.27) ---------------------------------------------------------------------------- / var(e.y) 0.453*** 0.183*** (3.74) (5.41) sigma 0.673*** 0.284*** (7.47) (11.12) ---------------------------------------------------------------------------- N 74 74 74 74 ---------------------------------------------------------------------------- t statistics in parentheses * p<0.05, ** p<0.01, *** p<0.001
Comment