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.

36 lines
607 B
Plaintext

7 months ago
program define raschres,rclass
syntax varlist [, resname(string)]
tempname diff theta
matrix `diff'=r(beta)
matrix `theta'=r(theta)
if "`resname'"=="" {
local resname=res
}
tokenize `varlist'
local nbitems: word count `varlist'
tempname score lt
genscore `varlist',score(`score')
gen `lt'=.
forvalues i=0/`nbitems' {
replace `lt'=`theta'[1,`i'] if `score'==`i'
}
forvalues i=1/`nbitems'{
tempname p`i' res`i'
gen `p`i''=exp(`lt'-`diff'[1,`i'])/(1+exp(`lt'-`diff'[1,`i'])
gen `resname'`i'=(1-`p`i'')/sqrt(`p`i''*(1-`p`i''))
}
pca `resname'*
end