You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
251 lines
4.8 KiB
Plaintext
251 lines
4.8 KiB
Plaintext
capture program drop descitems
|
|
program descitems
|
|
syntax varlist, PARTition(numlist integer >0)
|
|
local i = 1
|
|
|
|
local C = 0
|
|
foreach z in `partition' {
|
|
local C = `C' + `z'
|
|
}
|
|
|
|
local nbvars : word count `varlist'
|
|
|
|
if `C' != `nbvars' {
|
|
di in red "The sum of the numbers in the partition option is different from the number of variables precised in varlist"
|
|
exit 119
|
|
}
|
|
|
|
|
|
local i = 1
|
|
foreach x in `varlist' {
|
|
local var`i' = "`x'"
|
|
local `++i'
|
|
}
|
|
|
|
/*
|
|
qui su `var1'
|
|
local min = r(min)
|
|
local max = r(max)
|
|
|
|
forvalue i=2/`nbvars' {
|
|
qui su `var`i''
|
|
local minloc = r(min)
|
|
local maxloc = r(max)
|
|
if `minloc'<`min' local min = `minloc'
|
|
if `maxloc'>`max' local max = `maxloc'
|
|
}
|
|
*/
|
|
|
|
foreach var in `varlist' {
|
|
qui replace `var' = round(`var')
|
|
}
|
|
|
|
local lev = ""
|
|
foreach var in `varlist' {
|
|
qui levelsof `var', local(levels)
|
|
foreach l in `levels' {
|
|
if strpos("`lev'","`l'") == 0 {
|
|
local lev `lev' `l'
|
|
}
|
|
}
|
|
}
|
|
|
|
_qsort_index `lev'
|
|
local lev = r(slist1)
|
|
|
|
local i = 1
|
|
matrix d = J(`nbvars',4,.)
|
|
|
|
foreach var in `varlist'{
|
|
qui count if missing(`var')
|
|
local ct=r(N)
|
|
|
|
local tx`i'=`ct'/_N
|
|
matrix d[`i',1] = `tx`i''
|
|
local `i++'
|
|
}
|
|
|
|
matrix rownames d = `varlist'
|
|
matrix colnames d = "missing" "alpha" "Hj"
|
|
|
|
local i = 1
|
|
local y = 1
|
|
foreach x in `partition' {
|
|
|
|
if `i' == 1 local s = `x'
|
|
else local s = `s' +`x'
|
|
|
|
local liste = ""
|
|
forvalues w = `y'/`s' {
|
|
local liste `liste' `var`w''
|
|
}
|
|
|
|
qui capture alpha `liste', asi item std
|
|
|
|
mat a = r(Alpha)
|
|
mat at = a'
|
|
|
|
qui capture loevh `liste', pairwise
|
|
matrix e = r(loevHj)
|
|
matrix et = e'
|
|
matrix ns = r(nbHjkNS)
|
|
matrix nst = ns'
|
|
|
|
local k = 0
|
|
forvalues j = `y'/`s' {
|
|
local k = `k'+1
|
|
matrix d[`j',2] = at[`k',1]
|
|
matrix d[`j',3] = et[`k',1]
|
|
matrix d[`j',4] = nst[`k',1]
|
|
|
|
}
|
|
local `i++'
|
|
local y = `s'+1
|
|
}
|
|
|
|
/* coupure noms des items */
|
|
/*
|
|
local i = 1
|
|
foreach s in `varlist' {
|
|
local len = length("`s'")
|
|
if `len' > 10 {
|
|
local c = substr("`s'",1,9)
|
|
local d = substr("`s'",-1,1)
|
|
local var`i' "`c'" "~" "`d'"
|
|
}
|
|
else local var`i' = "`s'"
|
|
*local v `v' `var`i''
|
|
local `++i'
|
|
}
|
|
|
|
|
|
local max = 3
|
|
forvalues i=1/`nbvars' {
|
|
local len = length("`var`i''")
|
|
if `len' > `max' local max = `len'
|
|
}
|
|
*/
|
|
|
|
local i = 1
|
|
foreach v in `varlist' {
|
|
local var`i' = abbrev("`v'",8)
|
|
local `++i'
|
|
}
|
|
|
|
local dec = 10
|
|
local col = `dec'
|
|
local b : word count `lev'
|
|
|
|
local i = 1
|
|
local j = 1
|
|
local y = 1
|
|
di in blue _col(`dec') "{bf:Missing}" _c
|
|
local col = `col'+11
|
|
di in blue _col(`=`col'+2') "{bf:N}" _c
|
|
|
|
local col = `col'+9
|
|
di _col(`col') "{bf:Response categories}" _c
|
|
local col = `dec'+18+8*`b'
|
|
di _col(`col') "{bf:Alpha}" _c
|
|
local col = `col'+9
|
|
di _col(`col') "{bf:Loevinger}" _c
|
|
local col = `col'+12
|
|
di _col(`col') "{bf:Number of}"
|
|
|
|
local col = `dec'-1
|
|
di _col(`col') "{bf:data rate}" _c
|
|
local col = `dec'+18
|
|
foreach m in `lev' {
|
|
di _col(`=`col'+2') "`m'" _c
|
|
local col = `col'+8
|
|
}
|
|
local col = `dec'+17+8*`b'
|
|
di as result _col(`col') "- item" _c
|
|
local col = `col'+10
|
|
di as result _col(`col') "Hj coeff" _c
|
|
local col = `col'+12
|
|
di as result _col(`col') "NS Hjk"
|
|
|
|
|
|
|
|
local ch = `dec'+18+8*`b'+29
|
|
di "{hline `ch'}"
|
|
|
|
local i = 1
|
|
foreach x in `varlist' {
|
|
local varo`i' = "`x'"
|
|
local `++i'
|
|
}
|
|
|
|
|
|
local y = 1
|
|
foreach p in `partition' {
|
|
|
|
if `j' == 1 local s = `p'
|
|
else local s = `s' +`p'
|
|
|
|
forvalues z = `y'/`s' {
|
|
local col = `dec'
|
|
di "{bf:`var`z''}" _c
|
|
local t = d[`z',1]
|
|
local t : di %8.2f `t'
|
|
di _col(`col') "{text:`t'}" _c
|
|
qui count if missing(`varo`z'')
|
|
local m = r(N)
|
|
local N = _N-`m'
|
|
local N : di %4.0f `N'
|
|
local col = `col'+10
|
|
di _col(`col') "{text:`N'}" _c
|
|
|
|
local col = `col'+8
|
|
foreach m in `lev' {
|
|
|
|
local f = 0
|
|
qui levelsof `varo`z'', local(levels)
|
|
foreach l in `levels' {
|
|
if strpos("`levels'","`m'") == 0 {
|
|
local f = 1
|
|
}
|
|
}
|
|
/*if `f' == 1 {
|
|
di _col(`=`col'+2') "_" _c
|
|
}*/
|
|
*else {
|
|
qui count if round(`varo`z'') == `m'
|
|
local n = r(N)
|
|
qui count if `varo`z'' != .
|
|
local d = r(N)
|
|
local e = `n'/`d'
|
|
local e : di %4.2f `e'
|
|
if `e' != 0 di _col(`=`col'-1')"{text:`e'}" _c
|
|
else di _col(`=`col'-1')"{text: -}" _c
|
|
|
|
*}
|
|
local col = `col'+8
|
|
}
|
|
local col = `dec'+18+8*`b'
|
|
local a = d[`z',2]
|
|
local a : di %4.2f `a'
|
|
di _col(`=`col'+1') "{text:`a'}" _c
|
|
local h = d[`z',3]
|
|
local h : di %5.2f `h'
|
|
local col = `col'+10
|
|
di _col(`=`col'+3') "{text:`h'}" _c
|
|
local ns = d[`z',4]
|
|
local ns : di %1.0f `ns'
|
|
local col = `col'+12
|
|
di _col(`=`col'+7') "{text:`ns'}"
|
|
|
|
|
|
}
|
|
local `i++'
|
|
local `j++'
|
|
local y = `s'+1
|
|
di "{dup `ch':-}"
|
|
}
|
|
end
|
|
|
|
*descitems iociociociociocicocio1-ioc37, part(4 4 7 3 3 4 7 5)
|
|
*descitems ptgi1-peur16, part(4 4 7 3 3 4 7 5)
|
|
*descitems x1-x30, part(5 5 5 5 5 4 1)
|