*! version 2.0.1  08feb2000
program define weiht_lf
	version 6.0
	local lnf "`1'"
        local I "`2'"
        local s "`3'" /* ln_sigma */
        local a "`4'" /* ln_alp */
	quietly {
 		local id : char _dta[st_id]
        	local t = "$ML_y1"
       		local t0 = "$EREGt0"
        	local d = "$EREGd"
	        tempvar  let et net net0 sig alp oo
		gen double `sig'=exp(`s')                 /* sigma */
		gen double `alp'=exp(`a')                 /* alpha */
	        gen double `net'=1+`sig'*exp(`I')*(`t'^`alp')
	        gen double `net0'=1+`sig'*exp(`I')*(`t0'^`alp')
	        gen double `et'=`net'^(-1/`sig')
	        gen double `let'= ln(`et')
		replace `lnf' = /*
		*/ `d'*(`I'+ln(`alp')+`alp'*ln(`t')-ln(`t')-ln(`net')) /*
		   */ -(1/`sig')*ln(`net') + (1/`sig')*ln(`net0')
		replace `lnf'=`lnf' + $EREGa
	}
end
exit