I am changing the xb part of the Tobit with some rather complicate non-linear function.
Apart from the fact that it does not converge, I am also not sure that I am passing it right.
Right now I am just leaving the equation blank () because otherwise it would pass it linearly. Is that correct?
See the example below. First, I reproduce the linear tobit which works. Then I change the procedure to account for the difference in the deterministic part of the model and it does not work.
PS: This is related to another post (https://www.statalist.org/forums/for...inear-function), but I thought I'd open a new thread for clarity.
Apart from the fact that it does not converge, I am also not sure that I am passing it right.
Right now I am just leaving the equation blank () because otherwise it would pass it linearly. Is that correct?
See the example below. First, I reproduce the linear tobit which works. Then I change the procedure to account for the difference in the deterministic part of the model and it does not work.
Code:
// Make data set seed 12553 clear set obs 10000 gen y = runiformint(0,10) gen x = runiformint(0,1) gen z = int(abs(rnormal() * 50)) ******************************************************************************** // Linear Tobit gen Il = (y==0) gen Iu = (y==10) cap program drop mytobit_gf0 program mytobit_gf0 args todo b lnfj tempvar xb sigma non_censored lower_censored upper_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' = (1 - Il - Iu) * (-ln(`sigma') + ln(normalden((y-`xb')/`sigma'))) qui gen double `lower_censored' = Il * ln(normal(-`xb'/`sigma')) qui gen double `upper_censored' = Iu * ln(1-normal((10-`xb')/`sigma')) qui replace `lnfj' = `non_censored' + `lower_censored' + `upper_censored' end ml model gf0 mytobit_gf0 (y = x z) /sigma ml maximize tobit y x z, ll(0) ul(10) ******************************************************************************** // Non-linear Tobit cap program drop nl_tobit program nl_tobit args todo b lnfj tempvar xb sigma gamma0 gamma1 lambda delta non_censored lower_censored upper_censored qui gen double `gamma1' = `b'[1,1] qui gen double `lambda' = `b'[1,2] qui gen double `gamma0' = `b'[1,3] qui gen double `delta' = `b'[1,4] qui gen double `sigma' = `b'[1,5] qui gen double `xb' = (1 + `lambda'*x) * (`gamma0' + `gamma1' * (((1+z)^(1-`delta') - 1)/(1-`delta'))) qui gen double `non_censored' = (1 - Iu) * (-ln(`sigma') + ln(normalden((y-`xb')/`sigma'))) qui gen double `upper_censored' = Iu * ln(1-normal((10-`xb')/`sigma')) qui replace `lnfj' = `non_censored' + `upper_censored' end ml model gf0 nl_tobit () /gamma1 /lambda /gamma0 /delta /sigma ml search ml maximize ml graph
PS: This is related to another post (https://www.statalist.org/forums/for...inear-function), but I thought I'd open a new thread for clarity.
Comment