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

📄 _coef_table.ado

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 ADO
📖 第 1 页 / 共 2 页
字号:
*! version 1.1.13  30mar2005
program _coef_table
	version 8.2
	if "`e(cmd)'" == "" {
		error 301
	}
	syntax [,				///
		COEFTitle(string)		///
		Level(cilevel)			///
		PLus				///
		NOFirst				///
		First				///
		NEQ(integer -1)			///
		NODIPARM			///
		NOTEST				///
		SEParator(integer 0)		///
		*				/// -eform/diparm- opts
	]

	if `: word count `first' `nofirst'' > 1 {
		di as err "options first and nofirst cannot be combined"
		exit 198
	}

	is_svysum `e(cmd)'
	local is_sum = r(is_svysum)

	// parse `options' for -eform()- and friends
	_get_eformopts , eformopts(`options') allowed(__all__) soptions
	local eform	`"`s(str)'"'
	local udiparm	`"`s(options)'"'
	local coeftitle = cond(`"`eform'"'==`""', `"`coeftitle'"', `"`eform'"')
	// `udiparm' should only contain -diparm()- options
	_get_diparmopts, diparmopts(`udiparm') level(`level')

	// ignore -diparm()- options; but checked for valid syntax anyway
	if "`nodiparm'" != "" {
		local udiparm
	}

	// get equation names for auxiliary parameters or extra equations
	local coleq : coleq e(b), quote
	local coleq : list clean coleq
	local coleq : list uniq coleq

	Chk4Scalars k_eq k_aux k_extra
	// check for total number of equations
	local k_eq 0
	Chk4PosInt k_eq
	if `k_eq' == 0 {
		local k_eq : word count `coleq'
	}
	else if `k_eq' > `:word count `coleq'' {
		di as err ///
"estimation command error: e(k_eq) is larger than the number of equations"
		exit 322
	}
	// check for auxiliary parameters
	local k_aux 0
	Chk4PosInt k_aux
	// check for extra equations
	local k_extra 0
	Chk4PosInt k_extra

	// check that the e(k_*) scalars add up correctly
	if `k_aux'`k_extra' {
		if `:word count `coleq'' != `k_eq' {
			di as err ///
"estimation command error: e(k_eq) does not equal the number of equations"
			exit 322
		}
	}

	// figure out how many equations -ereturn- is going to display
	if "`first'" != "" {
		local neq 1
	}
	if `neq' > 0 {
		// user only wants the `neq' equations
		local k_aux 0
		local k_extra 0
	}
	else if `neq' < 1 {
		// automatically determine neq
		local neq = `k_eq'-`k_aux'-`k_extra'
		if `neq' < 0 {
			if `k_aux' & `k_extra' {
				di as err ///
"estimation command error: e(k_eq) is less than e(k_aux) + e(k_extra)"
				exit 322
			}
			local name = cond(`k_aux',"k_aux","k_extra")
			di as err ///
"estimation command error: e(k_eq) is less than e(`name')"
			exit 322
		}
		if !`is_sum' & `neq' == 1 ///
		 & "`nofirst'" == "" & `k_extra' == 0 {
			local first first
		}
	}

	local k_eform 0
	if `"`e(cmd)'"' == "mlogit" {
		local k_eform = `k_eq'-`k_aux'-`k_extra'
	}
	else if `neq' {
		local k_eform 1
		Chk4NNInt k_eform
		if `k_eform' > `neq' {
			local k_eform 1
		}
	}

	local copy `"`coleq'"'
	forval j = 1/`k_eform' {
		gettoken eq copy : copy, quotes
		local efcoleq `"`efcoleq' `eq'"'
	}
	forval j = `=`k_eform'+1'/`neq' {
		gettoken eq copy : copy, quotes
		local noefcoleq `"`noefcoleq' `eq'"'
	}

	// auxiliary parameters, and their transforms
	if `k_aux' {
		if "`notest'" != "" {
			local prob noprob
		}
		local i1 = `neq' + 1
		local i2 = `neq' + `k_aux'
		local isep 0
		local COLON
		forval i = `i1'/`i2' {
			if `isep' & mod(`isep',`separator') == 0 {
				local COLON ":"
				local diparm `"`diparm' `COLON' __sep__"'
			}
			local eq : word `i' of `coleq'
			if `"`e(diparm_opt`i')'"' != "" {
				local eq `"`eq', `prob' `e(diparm_opt`i')'"'
			}
			else if "`prob'" != "" {
				local eq `"`eq', `prob'"'
			}
			local diparm `diparm' `COLON' `eq'
			local ++isep
			local COLON ":"
		}
		if `"`diparm'"' != "" {
			local diparm diparm(`diparm')
		}
	}
	if "`nodiparm'" == "" &	`"`e(diparm)'`e(diparm1)'`udiparm'"' != "" {
		GetEDiparm ediparm
		if `"`ediparm'"' != "" {
			if `"`diparm'"' != "" {
				local diparm `diparm' diparm(__sep__)
			}
			local diparm `diparm' `ediparm'
		}
		if `"`udiparm'"' != "" {
			if `"`diparm'"' != "" {
				local diparm `diparm' diparm(__sep__)
			}
			local diparm `"`diparm' `udiparm'"'
		}
	}
	// display extra equations
	if `k_extra' {
		local i1 = `neq' + `k_aux' + 1
		forval i = `i1'/`k_eq' {
			local eq : word `i' of `coleq'
			local extra `"`extra' "`eq'""'
		}
	}

	// display any constraints
	tempname cns error
	capture mat `cns' = get(Cns)
	if !c(rc) {
		matrix dispCns
	}

	local df_r .
	Chk4Int df_r

	local emats : e(matrices)
	if `:list posof "error" in emats' {
		matrix `error' = e(error)
		local erropt error(`error')
	}

	tempname z
	if missing(`df_r') {
		scalar `z' = invnorm((100+`level')/200)
	}
	else	scalar `z' = invttail(`df_r',(100-`level')/200)

	tempname Tab
	.`Tab' = ._tab.new, col(7) lmargin(0) ignore(.b)
	// column        1      2     3     4     5     6     7
	.`Tab'.width	13    |11    11     9     9    12    12
	.`Tab'.titlefmt  .   %11s  %12s   %7s     .  %24s     .
	.`Tab'.strfmt    .   %11s     .     .     .     .     .
	.`Tab'.pad       .      2     2     1     3     3     3
	.`Tab'.numfmt    .  %9.0g %9.0g %8.2f %5.3f %9.0g %9.0g
	.`Tab'.strcolor  . result    .     .     .     .     .
	// NOTE: Changing any of the above values should be reflected in
	// the ColumnTitles subroutine.  This may also affect
	// _coef_table_header.ado.

	if "`e(clustvar)'" != "" & !missing(e(N_clust)) {
		di as txt ///
"{ralign 78:(Std. Err. adjusted for {res:`e(N_clust)'} clusters in `e(clustvar)')}"
	}
	else if "`e(clustvar)'" != "" {
		di as txt ///
"{ralign 78:(Std. Err. adjusted for clustering on `e(clustvar)')}"
	}
	ColumnTitles `Tab' `level' `df_r' `"`coeftitle'"' `neq'

	if `"`efcoleq'"' != "" {
		DisplayEqns `efcoleq' :		///
			`Tab',	l(`level')	///
				df(`df_r')	///
				z(`z')		///
				ef(`eform')	///
				`first'		///
				`erropt'	///
				// blank
	}
	if `"`noefcoleq'"' != "" {
		DisplayEqns `noefcoleq' : ///
		`Tab', l(`level') df(`df_r') z(`z') `erropt'
	}
	if `"`diparm'"' != "" {
		.`Tab'.sep
		_get_diparmopts, level(`level')	diparmopts(`diparm') execute
	}
	if `"`extra'"' != "" {
		DisplayEqns `extra' : `Tab', l(`level') df(`df_r') z(`z')
	}
	if "`plus'" == "" {
		.`Tab'.sep, bottom
	}
	else	.`Tab'.sep

	if e(rc) == 504 & "`e(opt)'" == "ml" {
		di as err ///
"{p 0 0 2}variance matrix missing because `e(user)' failed" ///
"to compute scores or computed scores with missing values{p_end}"
		exit 504
	}
	if (!missing(e(rc)) & e(rc) != 0) error e(rc)
end

program ColumnTitles
	args Tab level df eform neq

	is_svysum `e(cmd)'
	local is_sum = r(is_svysum)

	local tsdvn 0		// number of depvar lines for time-series
				// operators to display

	if `is_sum' {
		if "`e(over)'" != "" {
			local depvar "Over"
		}
		local coef = proper("`e(cmd)'")
	}
	else {
		local coleq : coleq e(b)
		local dv `"`e(depvar)'"'
		local dv1 : word 1 of `dv'
		if `:word count `dv'' == 1 ///
		 & (`neq' <= 1 | !`:list dv in coleq') {
			gettoken op vn : dv, parse(".")
			if "`vn'" != "" & `:length local dv' > 12 {
				local vn = substr("`vn'",2,.)
				MLineTSop op_ depvar tsdvn : `op' `vn'
			}
			else	local depvar = abbrev("`dv'",12)
		}
		if "`eform'" != "" {
			local coef "`eform'"
		}
		else	local coef "Coef."
	}
	if missing(`df') {
		local stat z
	}
	else	local stat t
	.`Tab'.sep, top
	if `"`e(vcetype)'"' != "" {
		local vcetype `"`e(vcetype)'"'
		if "`e(vcetype)'" == "Bootstrap" {
			local obs "Observed"
			local citype "Normal-based"
		}
		local ciwd : length local citype
		local vcewd : length local vcetype
		if `"`e(mse)'"' != "" {
			capture which `e(vce)'_`e(mse)'.hlp
			if !c(rc) {
				local vcetype ///
				"{help `e(vce)'_`e(mse)'##|_new:`vcetype'}"
				local plus = `: length local vcetype' - `vcewd'
				local plus "+`plus'"
			}
		}
		if `vcewd' <= 12 {
			// NOTE: see the width and pad definitions of .`Tab'
			local vcewd = `vcewd'`plus' + ceil((12-`vcewd')/2+1)
		}
		if `ciwd' <= 27 {
			// NOTE: see the width and pad definitions of .`Tab'
			local ciwd = `ciwd' + ceil((27-`ciwd')/2)
		}
		// column        1       2             3   4  5          6  7
		.`Tab'.titlefmt  .       .     %`vcewd's   .  .   %`ciwd's  .
		.`Tab'.titles   "" "`obs'" `" `vcetype'"' "" "" "`citype'" ""
		.`Tab'.titlefmt  .       .          %12s   .  .       %24s  .
	}

⌨️ 快捷键说明

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