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

📄 _coef_table_header.ado

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 ADO
字号:
*! version 1.1.0  01apr2005
program _coef_table_header
	version 9
	syntax [, rclass noHeader noMODELtest TItle(string asis) nocluster ]

	if ("`header'" != "") exit

	tempname left right
	.`left' = {}
	.`right' = {}

	local is_svy = "`e(prefix)'" == "svy"
	local is_prefix = "`e(prefix)'" != "" 
	if `is_svy' {
		if "`rclass'" != "" {
			local 0 ", rclass"
			syntax [, NONOPTION ]
			exit 198
		}
		local e e
	}
	else {
		if "`rclass'" == "" {
			local e e
		}
		else	local e r
	}
	if "`e'" == "e" {
		is_svysum `e(cmd)'
		local is_sum `r(is_svysum)'
	}
	else {
		local is_sum 0
	}
	if `is_svy' {
		local is_tab = "`e(cmd)'" == "tabulate"
	}
	else	local is_tab 0

	if `is_sum' {
		local C1 _col(1)
		local C2 _col(18)
		local c3 = 37
		local C3 _col(`c3')
		local C4 _col(54)
		local wfmt 7
		local scheme compact
	}
	else if `is_prefix' {
		local C1 _col(1)
		local C2 _col(20)
		local c3 = 49
		local C3 _col(`c3')
		local C4 _col(68)
		local wfmt 9
		local scheme svy
	}
	else {
		local C1 _col(1)
		local C2 _col(18)
		local c3 = 51
		local C3 _col(`c3')
		local C4 _col(67)
		local wfmt 10
		local scheme ml
	}
	local max_len_title = `c3' - 2
	local sfmt %13s
	local ablen 14

	local wfmt1 = `wfmt' + 1
	if "`e'" == "r" & "`r(cmd)'" == "permute" {
		local is_prefix 1
	}

	// display title
	if `"`title'"' == "" {
		local title  `"``e'(title)'"'
		local title2 `"``e'(title2)'"'
	}

	// Left hand header *************************************************

	// display N strata
	if `is_prefix' & !missing(`e'(N_strata)) {
		.`left'.Arrpush					///
			`C1' "Number of strata" `C2' "= "	///
			as res %`wfmt'.0f `e'(N_strata)
	}

	// display number of PSU/clusters
	if `is_svy' & !missing(`e'(N_psu)) {
		.`left'.Arrpush					///
			`C1' "Number of PSUs" `C2' "= "		///
			as res %`wfmt'.0f `e'(N_psu)
	}

	// display N of poststrata
	if `is_svy' & !missing(`e'(N_poststrata)) {
		.`left'.Arrpush					///
			`C1' "N. of poststrata" `C2' "= "	///
			as res %`wfmt'.0f `e'(N_poststrata)
	}

	// display N of stdize strata
	if (`is_tab' | `is_sum') & !missing(`e'(N_stdize)) {
		.`left'.Arrpush					///
			`C1' "N. of std strata" `C2' "= "	///
			as res %`wfmt'.0f `e'(N_stdize)
	}

	// Right hand header ************************************************

	// display N obs
	.`right'.Arrpush					///
		`C3' "Number of obs" `C4' "= "			///
		as res %`wfmt'.0f `e'(N)

	if !`is_svy' & !missing(`e'(N_clust)) ///
	 & "`cluster'``e'(clustvar)'" == "" {
		if "`scheme'" != "svy" {
			local NumClust "N. of clusters"
		}
		else {
			local NumClust "Number of clusters"
		}
		.`right'.Arrpush				///
			`C3' "`NumClust'" `C4' "= "		///
			as res %`wfmt'.0f `e'(N_clust)
	}

	// display Pop size
	if `is_svy' & !missing(e(N_pop)) {
		.`right'.Arrpush				///
			`C3' "Population size" `C4' "="		///
			as res %`wfmt1'.0g e(N_pop)
	}

	// display subpop N obs and subpop size
	if `is_svy' & !missing(`e'(N_sub)) {
		if "`scheme'" == "compact" {
			local SubNobs "Subpop. no. obs"
		}
		else	local SubNobs "Subpop. no. of obs"
		.`right'.Arrpush				///
			`C3' "`SubNobs'" `C4' "="		///
			as res %`wfmt1'.0f `e'(N_sub)
		.`right'.Arrpush				///
			`C3' "Subpop. size" `C4' "="		///
			as res %`wfmt1'.0g `e'(N_subpop)
	}

	// display N of replications
	if !missing(`e'(N_reps)) {
		.`right'.Arrpush				///
			`C3' "Replications" `C4' "= "		///
			as res %`wfmt'.0f `e'(N_reps)
	}

	if `is_svy' & !missing(`e'(df_r)) {
		.`right'.Arrpush `C3' "Design df" `C4' "= "	///
			as res %`wfmt'.0f `e'(df_r)
	}

	if "`modeltest'" == "" & "`e'" == "e" & !missing(e(df_m)) {
		// display a model test
		if `"`e(chi2)'"' != "" {
			Chi2test `right' `C3' `C4' `wfmt'
		}
		else {
			Ftest `right' `C3' `C4' `wfmt' `is_svy'
		}
	}

	if "`e'" == "e" {
		// display R-squared
		if !missing(`e'(r2)) {
			.`right'.Arrpush			///
				`C3' "R-squared" `C4' "= "	///
				as res %`wfmt'.4f `e'(r2)
		}
		if !missing(`e'(r2_p)) {
			.`right'.Arrpush			///
				`C3' "Pseudo R2" `C4' "= "	///
				as res %`wfmt'.4f `e'(r2_p)
		}
		if !missing(`e'(r2_a)) {
			.`right'.Arrpush			///
				`C3' "Adj R-squared" `C4' "= "	///
				as res %`wfmt'.4f `e'(r2_a)
		}
		if !missing(`e'(rmse)) {
			.`right'.Arrpush			///
				`C3' "Root MSE" `C4' "= "	///
				as res %`wfmt'.4f `e'(rmse)
		}
	}

	// number of elements in the left header
	local kl = `.`left'.arrnels'
	if `"`title'"' != "" & `kl' == 0 {
		// make title line part of the header if it fits
		local len_title : length local title
		if `"`title2'"' != "" {
			local len_title = ///
			max(`len_title',`:length local title2')
		}
		if `len_title' < `max_len_title' {
			.`left'.Arrpush `"`"`title'"'"'
			local title
			if `"`title2'"' != "" {
				.`left'.Arrpush `"`"`title2'"'"'
				local title2
			}
		}
	}

	// put log likelihood at the bottom of the left header
	if "`e'" == "e" & !missing(e(ll)) & !missing(e(crittype)) {
		// number of elements in the right header
		local kr = `.`right'.arrnels'
		// number of elements in the left header
		local kl = `.`left'.arrnels'
		local space = `kr' - `kl' - 1
		forval i = 1/`space' {
			.`left'.Arrpush ""
		}
		local crtype = upper(substr(`"`e(crittype)'"',1,1)) + ///
			substr(`"`e(crittype)'"',2,.)
		.`left'.Arrpush `""`crtype' = " as res %10.0g e(ll)"'
	}

	Display `left' `right' `"`title'"' `"`title2'"'

end

program Display
	args left right title title2

	local nl = `.`left'.arrnels'
	local nr = `.`right'.arrnels'
	local K = max(`nl',`nr')

	di
	if `"`title'"' != "" {
		di as txt `"`title'"'
		if `"`title2'"' != "" {
			di as txt `"`title2'"'
		}
		di
	}

	local c _c
	forval i = 1/`K' {
		di as txt `.`left'[`i']' as txt `.`right'[`i']'
	}
end

program Ftest
	args right C3 C4 wfmt is_svy

	if `is_svy' & "`e(adjust)'" == "" {
		// -svy- F tests are adjusted by default
		if e(df_m) == 0 {
			local df = e(df_r)
		}
		else	local df = e(df_r) - e(df_m) + 1
	}
	else {
		local df = e(df_r)
	}
	if !missing(e(F)) {
		.`right'.Arrpush				///
			 `C3' "F("				///
		   as res %4.0f e(df_m)				///
		   as txt ","					///
		   as res %7.0f `df' as txt ")" `C4' "= "	///
		   as res %`wfmt'.2f e(F)
		.`right'.Arrpush				///
			 `C3' "Prob > F" `C4' "= "		///
		   as res %`wfmt'.4f Ftail(e(df_m),`df',e(F))
	}
	else {
		local dfm_l : di %4.0f e(df_m)
		local dfm_l2: di %7.0f `df'
		local j_robust "{help j_robustsingular##|_new:F(`dfm_l',`dfm_l2')}"
		.`right'.Arrpush				///
			  `C3' "`j_robust'"			///
		   as txt `C4' "= " as result %`wfmt's "."
		.`right'.Arrpush				///
			  `C3' "Prob > F" `C4' "= " as res %`wfmt's "."
	}
end

program Chi2test
	args right C3 C4 wfmt

	local type `e(chi2type)'
	if `"`type'"' == "" {
		local type Wald
	}
	if !missing(e(chi2)) {
		.`right'.Arrpush				///
		          `C3' "`type' chi2("			///
		   as res e(df_m)				///
		   as txt ")" `C4' "= "				///
		   as res %`wfmt'.2f e(chi2)
		.`right'.Arrpush				///
		          `C3' "Prob > chi2" `C4' "= "		///
		   as res %`wfmt'.4f chi2tail(e(df_m),e(chi2))
	}
	else {
		local j_robust					///
		"{help j_robustsingular##|_new:`type' chi2(`e(df_m)')}"
		.`right'.Arrpush				///
		          `C3' "`j_robust'"			///
		   as txt `C4' "= " as res %`wfmt's "."
		.`right'.Arrpush				///
		          `C3' "Prob > chi2" `C4' "= "		///
		   as res %`wfmt's "."
	}
end

exit

⌨️ 快捷键说明

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