-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdi.ado
40 lines (30 loc) · 1.14 KB
/
pdi.ado
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
*! version 1.1, Chao Wang, 16/02/2024
*! version 1.0, Chao Wang, 25/05/2022
* calculates polytomous discrimination index (PDI)
* see: Dover, DC, Islam, S, Westerhout, CM, Moore, LE, Kaul, P, Savu, A. Computing the polytomous discrimination index. Statistics in Medicine. 2021; 40: 3667– 3681. https://doi.org/10.1002/sim.8991
program pdi, rclass
version 16
syntax varlist(min=2 numeric) [if] [in]
marksample touse
gettoken depvar indepvar : varlist
local varnum: word count `indepvar'
tempname result
matrix `result'=J(`varnum',1,.)
matrix rownames `result'=`indepvar'
matrix colnames `result'="PDI #"
local pdi=0
forvalues i = 1/`varnum' {
local var: word `i' of `indepvar'
qui pdi_outcome `depvar' `var' if `touse', outcome(`i')
matrix `result'[`i',1]=r(pdi_outcome)
local pdi=`pdi'+`r(pdi_outcome)'
}
local pdi=`pdi'/`varnum'
di as text "The overall polytomous discrimination index (PDI) is: " as result %5.3f `pdi'
return scalar pdi=`pdi'
di ""
di as text "PDI for each outcome:"
local seps: di _dup(`varnum') "&"
matlist `result', cspec(& %6s | %9.3g o2&) rspec(&-`seps')
return matrix result `result'
end