canon_estat.ado

来自「是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到」· ADO 代码 · 共 107 行

ADO
107
字号
*! version 1.0.2  13feb2005
program canon_estat, rclass
	version 9

	if "`e(cmd)'" != "canon" {
		dis as err "canon estimation results not found"
		exit 301
	}

	gettoken key args: 0, parse(" ,")
	local lkey = length(`"`key'"')
	if `"`key'"' == substr("correlations",1,max(3, `lkey')) {
		Corrmat `args'
	}
	else if `"`key'"' == substr("loadings",1,max(3,`lkey')) {
		Loadings `args' 
	}
	else {
	
		estat_default `0'
	}
	return add
end

program define Corrmat, rclass
	syntax [, format(string)]

	if "`format'" =="" {
		local format format(%8.4f)
	} 
	else {
		quietly di `format' 0
		local format format(`format')
	}
	
	tempname corr_var1 corr_var2 corr_mixed
	mat `corr_var1' = e(corr_var1)
	mat `corr_var2' = e(corr_var2)
	mat `corr_mixed' = e(corr_mixed)
	
	di _n in green "Correlations for variable list 1"
	matlist `corr_var1', left(4) border(bottom) `format'
	
	di _n in green "Correlations for variable list 2"
	matlist `corr_var2', left(4) border(bottom) `format'

	di _n in green "Correlations between variable lists 1 and 2"
	matlist `corr_mixed', left(4) border(bottom) `format'
	di
	
	return matrix corr_var1 = `corr_var1'
	return matrix corr_var2 = `corr_var2'
	return matrix corr_mixed = `corr_mixed'
end

program define Loadings, rclass
	syntax [, format(string)]
	
	if "`format'" =="" {
		local format format(%8.4f)
	} 
	else {
		quietly di `format' 0
		local format format(`format')
	}
	
	tempname canload11 canload12 canload21 canload22
	mat `canload11'=e(canload11)
	mat `canload12'=e(canload12)
	mat `canload21'=e(canload21)
	mat `canload22'=e(canload22)
	local lc `e(n_lc)'
	local fir `e(n_first)'
	
	di
	if "`lc'" !="" {
		di in green "Linear combinations for canonical "	///
			"correlation `lc' calculated" _n
	}
	if "`fir'" != "" {
		di in green "Linear combinations for the first `fir' "	///
			"canonical correlations calculated" _n
	}
	
	di in green "Canonical loadings for variable list 1"
	matlist `canload11', left(4) border(bottom) `format'
	 
	di _n in green "Canonical loadings for variable list 2"
	matlist `canload22', left(4) border(bottom) `format'
		
	di _n in green "Correlation between variable list 1 and " ///
		"canonical variates from list 2"
	matlist `canload12', left(4) border(bottom) `format'
	
	di _n in green "Correlation between variable list 2 and " ///
		"canonical variates from list 1"
	matlist `canload21', left(4) border(bottom) `format'
	di
	
	return matrix canload11 = `canload11'
	return matrix canload12 = `canload12'
	return matrix canload21 = `canload21'
	return matrix canload22 = `canload22'
end

exit

⌨️ 快捷键说明

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