Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FW: st: AW: problem with -contract-


From   "Karen Wright" <[email protected]>
To   <[email protected]>
Subject   Re: FW: st: AW: problem with -contract-
Date   Wed, 06 Jan 2010 14:52:03 +0000

It is a generalized weighted kappa for multiple readers.  The code that I have written to do the calculations is very basic and will probably make you experienced programmers cringe!  I attempted writting my own program but gave up and just used seperate commands to give out the answer I require.  Unfortunately i also run into problems with  extending the code to deal with any greater than 5 readers as I generate variables.  i can post the commands (below), but as I say they are guaranteed not the best/efficient/etc way to do the calculations!

the data entered is contracted (using the zero option) with each variable named reader1, reader2, reader3, etc.

for three readers the code is:

***********
loc m = 3
loc r = 4

*Generate the weights:
forval i=1/`m' {
	forval j=`i'/`m' {
		gen w_`i'`j' = abs(reader`i' - reader`j')
	}
}
egen weight = rowtotal(w*)
drop w_*

summ _freq, detail
loc nobs = r(sum)
loc n2 = `nobs'^2
di `n2'
gen wn = weight*_freq
summ wn
loc w_n = r(sum)
loc numer = `w_n'*`n2'
di `numer'

forval a=1/`r' {
	summ _freq if reader1==`a' 
	loc A_`a' = r(sum)
	summ _freq if reader2==`a' 
	loc B_`a' = r(sum)
	summ _freq if reader3==`a' 
	loc C_`a' = r(sum)
}
forval a=1/4 {
	forval b=1/4 {
		forval c=1/4 {
qui gen d_`a'`b'`c' = weight*`A_`a''*`B_`b''*`C_`c'' if reader1==`a' & reader2==`b' & reader3==`c'
		}
	}
}
egen den = rowtotal(d_111-d_`r'`r'`r')
drop d_*
summ(den)
loc denom = r(sum)
di `denom'
loc k=`numer'/`denom'
loc kappa = 1 - `k'
di `kappa'

************


>>> Maarten buis <[email protected]> 06/01/2010 14:39 >>>
--- On Wed, 6/1/10, Karen Wright wrote:
> It is to be used in calculations
> which require all of the combinations
> to be present.

There is usually a way around that, but
we obviously cannot tell you what that is, 
if you don't tell is what that computation
is.

-- Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl 
--------------------------


      

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search 
*   http://www.stata.com/support/statalist/faq 
*   http://www.ats.ucla.edu/stat/stata/


The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the addressee only.  If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer and network.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index