Hi guys, I have one question regarding likelihood estimation, I want to estimate the parameters (alfa eps_b eps_s mu delta) of the likelihood function (see eq1 attached below), and I write the program like this:
program define destri_lf
version 11.0
args lnf epsb epss alfa mu delta
quietly replace `lnf'=-`epsb'-`epss'+($ML_y1+$ML_y2/2)*(ln(`epsb'/(`mu'+`epsb'))+ln(`epss'/(`mu'+`epss'))) + $ML_y1*ln(`mu'+`epsb') + $ML_y2*ln(`mu'+`epss') + ln(`alfa'*(1-`delta')*exp(-`mu')*((`epss'/(`mu'+`epss'))^($ML_y2/2-$ML_y1))*(`epsb'/(`mu'+`epsb'))^(-$ML_y1-$ML_y2/2) + `alfa'*`delta'*exp(-`mu')*((`epss'/(`mu'+`epss'))^(-$ML_y2/2-$ML_y1))*(`epsb'/(`mu'+`epsb'))^(-$ML_y2/2) + (1-`alfa')*((`epss'/(`mu'+`epss'))^($ML_y2/2-$ML_y1))*(`epsb'/(`mu'+`epsb'))^(-$ML_y2/2)) if $ML_y2>=$ML_y1
quietly replace `lnf'=-`epsb'-`epss'+($ML_y2+$ML_y1/2)*(ln(`epsb'/(`mu'+`epsb'))+ln(`epss'/(`mu'+`epss'))) + $ML_y1*ln(`mu'+`epsb') + $ML_y2*ln(`mu'+`epss') + ln(`alfa'*(1-`delta')*exp(-`mu')*((`epss'/(`mu'+`epss'))^(-$ML_y1/2))*(`epsb'/(`mu'+`epsb'))^(-$ML_y2-$ML_y1/2) + `alfa'*`delta'*exp(-`mu')*((`epss'/(`mu'+`epss'))^(-$ML_y1/2-$ML_y2))*(`epsb'/(`mu'+`epsb'))^(-$ML_y1/2-$ML_y2) + (1-`alfa')*((`epss'/(`mu'+`epss'))^(-$ML_y1/2))*(`epsb'/(`mu'+`epsb'))^(-$ML_y1/2-$ML_y2)) if $ML_y2<$ML_y1
end
but when I run ml model using the following code:
set more off
sysuse auto,clear
gen cons=1
ml model lf destri_lf (epsb:mpg=) (epss:turn=) /alfa /mu /delta
ml check
ml maximize
it just show the error information like this;
. ml maximize
initial: log likelihood = 11416.282
rescale: log likelihood = 11416.282
rescale eq: log likelihood = 60246.81
could not calculate numerical derivatives -- flat or discontinuous region encountered
r(430);
end of do-file
r(430);
can anyone tell me what should I do with the program? thanks
program define destri_lf
version 11.0
args lnf epsb epss alfa mu delta
quietly replace `lnf'=-`epsb'-`epss'+($ML_y1+$ML_y2/2)*(ln(`epsb'/(`mu'+`epsb'))+ln(`epss'/(`mu'+`epss'))) + $ML_y1*ln(`mu'+`epsb') + $ML_y2*ln(`mu'+`epss') + ln(`alfa'*(1-`delta')*exp(-`mu')*((`epss'/(`mu'+`epss'))^($ML_y2/2-$ML_y1))*(`epsb'/(`mu'+`epsb'))^(-$ML_y1-$ML_y2/2) + `alfa'*`delta'*exp(-`mu')*((`epss'/(`mu'+`epss'))^(-$ML_y2/2-$ML_y1))*(`epsb'/(`mu'+`epsb'))^(-$ML_y2/2) + (1-`alfa')*((`epss'/(`mu'+`epss'))^($ML_y2/2-$ML_y1))*(`epsb'/(`mu'+`epsb'))^(-$ML_y2/2)) if $ML_y2>=$ML_y1
quietly replace `lnf'=-`epsb'-`epss'+($ML_y2+$ML_y1/2)*(ln(`epsb'/(`mu'+`epsb'))+ln(`epss'/(`mu'+`epss'))) + $ML_y1*ln(`mu'+`epsb') + $ML_y2*ln(`mu'+`epss') + ln(`alfa'*(1-`delta')*exp(-`mu')*((`epss'/(`mu'+`epss'))^(-$ML_y1/2))*(`epsb'/(`mu'+`epsb'))^(-$ML_y2-$ML_y1/2) + `alfa'*`delta'*exp(-`mu')*((`epss'/(`mu'+`epss'))^(-$ML_y1/2-$ML_y2))*(`epsb'/(`mu'+`epsb'))^(-$ML_y1/2-$ML_y2) + (1-`alfa')*((`epss'/(`mu'+`epss'))^(-$ML_y1/2))*(`epsb'/(`mu'+`epsb'))^(-$ML_y1/2-$ML_y2)) if $ML_y2<$ML_y1
end
but when I run ml model using the following code:
set more off
sysuse auto,clear
gen cons=1
ml model lf destri_lf (epsb:mpg=) (epss:turn=) /alfa /mu /delta
ml check
ml maximize
it just show the error information like this;
. ml maximize
initial: log likelihood = 11416.282
rescale: log likelihood = 11416.282
rescale eq: log likelihood = 60246.81
could not calculate numerical derivatives -- flat or discontinuous region encountered
r(430);
end of do-file
r(430);
can anyone tell me what should I do with the program? thanks