*! version 2.0.1  08feb2000
program define lncur_lf
	version 6.0

	  local lnf "`1'"
        local I "`2'"
        local s "`3'" /* ln_sigma */
        local a "`4'" /* ln_c */
	quietly {
 	     	local t = "$ML_y1"
      	local t0 = "$EREGt0"
        	local d = "$EREGd"
		tempname  es e2s
		tempvar  lntxb lntxb0 et et0 c
		scalar `es' = exp(`s')
		scalar `e2s' = exp(2*`s')
		scalar `c' = exp(`a')
		gen double `lntxb'=(ln(`t')-`I')/`es'
		gen double `lntxb0'=(ln(`t0')-`I')/`es' if `t0'>0
            gen double `et'= `c'+(1-`c')*(1-normprob(`lntxb'))
	      gen double `et0'=cond(`t0'==0, 0, `c'+(1-`c')*(1-normprob(`lntxb0')))
		replace `lnf' = `d'*(ln(`c')+ln(1-`c')-0.5*ln(2*_pi)-ln(`t')-`s' /*
			*/ -((`lntxb'^2)/2) - ln(`et')) + ln(`et') /*
			*/ - cond(`t0'>0, ln(`et0'), 0)
		scalar `lnf'=`lnf'+$EREGa
	}
end
exit