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

📄 alpha.ado

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 ADO
📖 第 1 页 / 共 2 页
字号:
	local linesize : set linesize

	/*
		compact output if -item- is not specified
	*/

	if "`item'" == "" {
		if "`std'" == "" {
			local lab "covariance"
			local fmt "%9.0g"
		}
		else {
			local lab "correlation"
			local fmt "%9.4f"
		}
 		if "`revlist'" != "" {
 			local nrev : word count `revlist'
			local itemtxt = cond(`nrev'>1, "items", "item")
			di as txt "Reversed `itemtxt': {res:`revlist'}"
		}
		di
		di as txt "Average interitem `lab':"       _col(34) as res `fmt' `acorr'
		di as txt "Number of items in the scale:"  _col(34) as res %9.0f `k'
		di as txt "Scale reliability coefficient:" _col(34) as res %9.4f `alpha'
	}

	/*
		item is specified, no label
	*/

	if "`item'" != "" & "`label'" == "" {
		if "`std'" == "" {
			local lab "covariance "
			local fmt "%9.0g"
		}
		else {
			local lab "correlation"
			local fmt "%9.4f"
		}

    		di as txt _n "                                                            average"
		di as txt    "                             item-test     item-rest      inter-item"
		di as txt "Item         {c |}  Obs  Sign   correlation   correlation     `lab'     alpha"
		di as txt "{hline 13}{c +}{hline 65}"
		forvalues i = 1/`k' {
			di as txt abbrev("``i''",12) "{col 14}{c |}" as res /*
			 */ _col(16) %4.0f `Obs'[`i',`i'] /*
			 */ _col(24)       =cond("`sgn`i''"=="1","+","-") /*
			 */ _col(31) %7.4f `ITC'[1,`i']   /*
			 */ _col(45) %7.4f `IRC'[1,`i']   /*
			 */ _col(59) `fmt' `mIIC'[1,`i']  /*
			 */ _col(73) %7.4f `alph'[1,`i']
		}
		di as txt "{hline 13}{c +}{hline 65}"
		di as txt "Test scale{col 14}{c |}" /*
		 */ as res _col(59) `fmt' `acorr' _col(73) %7.4f `alpha'
		di as txt "{hline 13}{c BT}{hline 65}"
	}

	/*
		item and label specified; linesize<100
	*/

	if "`item'" != "" & "`label'" != "" & `linesize' < 100 {
		if "`std'" == "" {
			local lab "cov"
			local fmt "%7.0g"
		}
		else {
			local lab "cor"
			local fmt "%7.3f"
		}

		MaxVarLab "`varlist'"
		local lenlabel = max(r(llen),length(`"`testtxt'"'))
		local lenpiece = min(`lenlabel',`linesize'-52)
		local duplen   = 38 + `lenpiece'

		di _n as txt "Items        {c |} S  it-cor  ir-cor   ii-`lab'   alpha   label"
		di    as txt "{hline 13}{c +}{hline `duplen'}"
		forvalues i = 1/`k' {
			di as txt abbrev("``i''", 12) "{col 14}{c |} " as res /*
		 	 */          =cond("`sgn`i''" == "1", "+", "-") /*
			 */ _col(19) %6.3f `ITC'[1,`i']           /*
			 */ _col(27) %6.3f `IRC'[1,`i']           /*
			 */ _col(35) `fmt' `mIIC'[1,`i']          /*
			 */ _col(44) %6.3f `alph'[1,`i']          /*
			 */ _col(53) _c

			DiVarLab ``i'' `lenpiece' 55
		}

		di as txt "{hline 13}{c +}{hline `duplen'}"
		di as txt "Test scale{col 14}{c |}" as res /*
		 */ _col(35) `fmt' `acorr' /*
		 */ _col(44) %6.3f `alpha' /*
		 */ _col(53) as txt `"`testtxt'"'
		di as txt "{hline 13}{c BT}{hline `duplen'}"
	}

	/*
		item and label specified; linesize>=100
	*/

	if "`item'" != "" & "`label'" != "" & `linesize' >= 100 {
		if "`std'" == "" {
			local lab "covariance "
			local fmt "%9.0g"
		}
		else {
			local lab "correlation"
			local fmt "%8.4f"
		}
		MaxVarLab "`varlist'"
		local lenlabel = max(r(llen),length(`"`testtxt'"'))
		local lenpiece = min(`lenlabel',`linesize'-69)
		local duplen   = 55 + `lenpiece'

		di
		di as txt "                          item-test  item-rest  inter-item"
		di as txt "Item         {c |}  Obs  Sign   corr.      corr.       corr.     alpha   Label"
		di    as txt "{hline 13}{c +}{hline `duplen'}"

		forvalues i = 1/`k' {
			di as txt abbrev("``i''", 12) "{col 14}{c |} " as res /*
			 */ _col(16) %4.0f `Obs'[1,`i']   /*
			 */ _col(24)       =cond("`sgn`i''" == "1", "+", "-") /*
			 */ _col(28) %7.4f `ITC'[1,`i']   /*
			 */ _col(39) %7.4f `IRC'[1,`i']   /*
			 */ _col(49) `fmt' `mIIC'[1,`i']  /*
			 */ _col(61) %6.4f `alph'[1,`i']  /*
			 */ _col(70) _c

			DiVarLab ``i'' `lenpiece' 72
		}

		di as txt "{hline 13}{c +}{hline `duplen'}"
		di as txt "Test scale{col 14}{c |}" as res /*
		 */ _col(49) `fmt' `acorr' /*
		 */ _col(61) %6.4f `alpha' /*
		 */ _col(70) as txt `"`testtxt'"'
		di as txt "{hline 13}{c BT}{hline `duplen'}"
	}

	* --------------------------------------------------------------------------
	* detail: table with interitem correlations / covariances
	* --------------------------------------------------------------------------

	if "`detail'" != "" {
		if `N' == `NC' {
			local obs "(obs=`N' in all pairs)"
		}
		else {
			local obs "(obs=pairwise, see below)"
		}

		if "`revlist'" != "" {
			local rev "(reverse applied) "
		}

		mat rownames `C' = `varlist'
		mat colnames `C' = `varlist'

		if "`std'" != "" {
			di as txt _n "Interitem correlations `rev'`obs'"
			mat list `C', noheader format(%6.4f)
		}
		else {
			di as txt _n "Interitem covariances `rev'`obs'"
			mat list `C', noheader format(%9.4f)
		}

		if `N' != `NC' {
			di as txt _n "Pairwise number of observations"
			mat rownames `Obs' = `varlist'
			mat colnames `Obs' = `varlist'
			mat list `Obs', noheader format(%5.0f)
		}
	}

	* --------------------------------------------------------------------------
	* generate(): save test scale
	* --------------------------------------------------------------------------

	if "`generate'" != "" {
		confirm new var `generate'
		qui gen `generate' = `test' if `touse'
		label var `generate' "mean(`un'standardized items)"
	}

	if "`item'" != "" {
		* information about rest-scales
		matrix colnames `ITC'  = `varlist'
		matrix colnames `IRC'  = `varlist'
		matrix colnames `mIIC' = `varlist'
		matrix colnames `alph' = `varlist'
		return matrix ItemTestCorr `ITC'
		return matrix ItemRestCorr `IRC'
		if "`std'" == "" {
			return matrix MeanInterItemCov `mIIC'
		}
		else {
			return matrix MeanInterItemCorr `mIIC'
		}
		return matrix Alpha `alph'
	}
end

* ============================================================================
* subroutines
* ============================================================================

/* ListIndex list word
   returns in r(index) the index of word in list, or 0 if not found
*/
program define ListIndex, rclass
	args list word

	local word = trim(`"`word'"')
	tokenize `list'
	local i 1
	local ifound 0
	while "``i''" != ""  & `ifound' == 0 {
		if "``i''" == `"`word'"' {
			local ifound `i'
		}
		local i = `i'+1
	}
	return local index `ifound'
end

/* MaxVarLab "varlist"
   returns in scalar r(vlen) the maximum length of the names of variables in a varlist,
                 and r(llen) the maximum variable length of thse variables
*/
program define MaxVarLab, rclass
	args varlist

	tempname llen vlen
	scalar `llen' = 0
	scalar `vlen' = 0
	foreach v of local varlist {
		scalar `vlen' = max(`vlen', length("`v'"))
		local vl : var label `v'
		scalar `llen' = max(`llen', length(`"`vl'"'))
	}
	return scalar vlen = `vlen'
	return scalar llen = `llen'
end


/* DiVarLab v lpiece col
   displays the varlabel of variable v, starting at the current cursor
   location, in pieces of length lpiece, with further pieces starting
   at position col.
*/
program define DiVarLab
	args v lpiece col

	local vlab : var label `v'
	local vl : piece 1 `lpiece' of `"`vlab'"'
	di as txt `"`vl'"'
	local j 2
	local vl : piece `j' `lpiece' of `"`vlab'"'
	while `"`vl'"' != "" {
		di as txt `"{col 14}{c |}{col `col'}`vl'"'
		local j = `j'+1
		local vl : piece `j' `lpiece' of `"`vlab'"'
	}
end

/* DropDup newlist : quoted-list
   drops all duplicate tokens from list -- copied from hausman.ado
*/
program DropDup
	args newlist	///  name of macro to store new list
	     colon      ///  ":"
	     list       //   list with possible duplicates

	gettoken token list : list
	while "`token'" != "" {
		local fixlist `fixlist' `token'
		local list : subinstr local list "`token'" "", word all
		gettoken token list : list
	}

	c_local `newlist' `fixlist'
end

exit

HISTORY

4.7.2  drops duplicate vars;
       bug fix: after dropping constant or duplicate variables there
         should still be >=2 vars;
       bug fix: location in code of check whether "item suppressed"

4.7.1  added varlist as row/column labels in corr/cov of items

4.7.0  missing values in results
       fixed bug with constant variables
       fixed minor display "bug"

4.5.1  fixed bug in restlist
       fixed bug in the varlabel of the generated variable
       negative alpha's in sublists are also shown as missing

4.5.0  ported to version 7

4.4.1  fixed some misalignments in labels

4.4.0  various minor changes in coding and layout
       additional checks
       -- N>0
       -- drop constant variables
       -- with incomplete data: check that there are >=2 obs for each pair
          of variables

4.3.0  return extra results

4.2.0  support for -display linesize-

4.1.0  ListIndx no longer returns values via macro S_1

4.0.4  improved varlabel handling in with option -label

4.0.3  added option numeric to varlist
       improved handling of long variable labels, and labels than contain quotes
       bug fix: -nvar=2, item-
       used matrix expressions
       modified display of signs in detail tables (the old version would crash
       if the name of a reversed variable was 8 char


⌨️ 快捷键说明

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