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

📄 procrustes_p.ado

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 ADO
字号:
*! version 1.0.0  02mar2005
program procrustes_p
	version 8

	if "`e(cmd)'" != "procrustes" {
		error 301
	}

// retrieve estimation results

	tempname A b c rho
	
	matrix `A'   = e(A)
	matrix `c'   = e(c)
	scalar `rho' = e(rho)

	local ylist `e(ylist)'
	confirm numeric variable `ylist'
	
	local xlist `e(xlist)'
	confirm numeric variable `xlist'

// parse

	syntax newvarlist [if] [in] [, FITted RESiduals Q ]

	local opts `fitted' `q' `residuals'
	local nopt : list sizeof opts
	if `nopt' > 1 {
		dis as err "options `opts' are exclusive"
		exit 198
	}
	if `nopt' == 0 {
		dis as txt "(fitted assumed)"
		local fitted fitted
	}
	
	local nvar : list sizeof varlist
	local na   = colsof(`A') // number of yvars

	if "`fitted'" != "" | "`residuals'" != "" {
		if `nvar' != `na' {
			dis as err "`na' new variables expected, `nvar' found"
			exit =cond(`na'>`nvar',102,103)
		}
	}
	
	if "`q'" != "" {
		if `nvar' != 1 {
			dis as err "one new variable expected"
			exit 103
		}
	}

// create variables

	marksample touse, novarlist

	local outvar `varlist'
	local outtp  `typlist'

	tempname yhat
	if "`q'" != "" {
		gen `typlist' `varlist' = 0 if `touse'
		label var `varlist' "procrustes: rss"
	}
	
	forvalues iy = 1 / `na' {
		gettoken y  ylist : ylist

		capture drop `yhat'
		matrix `b' = `A'[1...,`iy']'
		matrix score double `yhat' = `b' if `touse'
		quietly replace `yhat' = `rho'*`yhat'  + `c'[1,`iy'] if `touse'

		if "`fitted'" != "" {
			gettoken v  varlist : varlist
			gettoken tp typlist : typlist

			quietly gen `tp' `v' = `yhat'
			label var `v' "procrustes: approx `y'"
		}
		
		else if "`residuals'" != "" {
			gettoken v  varlist : varlist
			gettoken tp typlist : typlist

			quietly gen `tp' `v' = `y' - `yhat'
			label var `v' "procrustes: residual `y'"
		}
		
		else if "`q'" != "" {
			quietly replace `varlist' = `varlist' + (`y'-`yhat')^2
		}
		
		else {
			_stata_internalerror
		}
	}

// missing value messages

	foreach v of local outvar {
		quietly count if missing(`vt')
		local n = r(N)
		if `n' > 0 {
			dis as txt "(`v': `n' " /// 
			    plural(`n',"missing value") " generated)"
		}
	}
end
exit

⌨️ 快捷键说明

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