⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ml_elf.ado

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 ADO
字号:
*! version 3.1.3  21apr2003
program define ml_elf
	version 8.0
	args calltype
	// no need to check memory requirements
	if (`calltype' == -1) exit

	local i 1
	while `i' <= $ML_n {
		tempname x`i'
		qui mat score double `x`i'' = $ML_b if $ML_samp, eq(#`i')
		if "${ML_xo`i'}${ML_xe`i'}" != "" {
			if "${ML_xo`i'}" != "" {
				qui replace `x`i'' = `x`i'' + ${ML_xo`i'}
			}
			else 	qui replace `x`i'' = `x`i'' + ln(${ML_xe`i'})
		}
		local list `list' `x`i''
		local i = `i' + 1
	}

	tempvar f
	qui gen double `f' = . in 1

	$ML_vers $ML_user `f' `list'

	mlsum $ML_f = `f'

	if (`calltype'==0 | scalar($ML_f)==.) exit

				/* we now continue to make derivative
				   calculations
				*/
	tempname nfac wrk
	tempvar one x0 grad xj0 fphh fmhh Dii Dij

	mat $ML_g = J(1,$ML_k,0)
	mat $ML_V = J($ML_k, $ML_k, 0)
	qui gen byte `one' = 1 if $ML_samp

	quietly {
		local i 1
		while `i'<=$ML_n {
			if "${ML_xc`i'}" == "nocons" {
				local vl`i' ${ML_x`i'}
			}
			else 	local vl`i' ${ML_x`i'} `one'

			local se ${ML_fp`i'}
			local ee ${ML_lp`i'}

			tempname h`i'
			tempvar fph`i' fmh`i'

			rename `x`i'' `x0'

						/* calculate stepsize `h`i'',
						   `fph`i'', and `fmh`i'' */

  		 	noi ml_adjs elf `i' `fph`i'' `fmh`i'' `x0' `list'
			scalar `h`i'' = r(step)

						/* gradient calculation */

			gen double `grad'=$ML_w*(`fph`i''-`fmh`i'')/(2*`h`i'')
			matrix vecaccum `wrk' = `grad' `vl`i'', nocons
			mat subst $ML_g[1,`se'] = `wrk'
			drop `grad'
					 	/* Dii calculation */

			gen double `Dii' = $ML_w* /*
				*/ (`fph`i''-2*`f'+`fmh`i'')/(`h`i''^2)
			summ `Dii' if $ML_samp, meanonly
			scalar `nfac' = r(mean)
/* using wrk */
			matrix accum `wrk'= `vl`i'' [iw=-`Dii'/`nfac'], nocons
			if r(N)!=0 {
				mat `wrk' = `wrk' * `nfac'
				mat subst $ML_V[`se',`se'] = `wrk'
			}
/* wrk now free */
			drop `Dii'
			if `calltype'==2 { 		/* Dij calculation */
				local nei = `ee' - `se' + 1
				local nei1 = `nei' + 1
				local j 1
				while `j' < `i' { /* wrap */
rename `x`j'' `xj0'
gen double `x`j'' = `xj0' + `h`j''
gen double `fphh' = . in 1
noi $ML_vers $ML_user `fphh' `list'

drop `x`j''
gen double `x`j'' = `xj0' - `h`j''
replace `x`i'' = `x0' - `h`i''
gen double `fmhh' = . in 1
noi $ML_vers $ML_user `fmhh' `list'
replace `x`i'' = `x0' + `h`i''
drop `x`j''

gen double `Dij' = $ML_w * /*
*/ (`fphh'+`fmhh'+2*`f'-`fph`i''-`fmh`i''-`fph`j''-`fmh`j'' ) /*
*/ / (2*`h`i''*`h`j'')

* gen double `Dij' = $ML_w * (`fphh'-`fph`i''-`fph`j''+`f')/(`h`i''*`h`j'')
summ `Dij' if $ML_samp, meanonly
scalar `nfac' = r(mean)
								/* use wrk */
mat accum `wrk' = `vl`i'' `vl`j'' [iw=-`Dij'/`nfac'], nocons
if r(N) != 0 {
	mat `wrk' = `wrk'[1..`nei',`nei1'...]
	mat `wrk' = `wrk' * `nfac'

	local sej ${ML_fp`j'}

	mat subst $ML_V[`se',`sej'] = `wrk'
	mat `wrk' = `wrk' '
	mat subst $ML_V[`sej',`se'] = `wrk'
}
								/* wrk free */
drop `Dij' `fphh' `fmhh'
rename `xj0' `x`j''

local j=`j'+1
				} /* wrap */
			} /* Dij */

			drop `x`i''
			rename `x0' `x`i''

			local i=`i'+1
		} /* i loop */
	} /* quietly */
end
exit

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -