Statalist


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

RE: st: RE: kappa command: select raters with complete data


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: kappa command: select raters with complete data
Date   Sat, 5 Sep 2009 16:55:50 +0100

Evidently I didn't read your post carefully enough. 

It's best to stick to Stata terminology in posing Stata questions (e.g.
in Stataspeak variables always and only means columns). There are plenty
of words Stata hasn't claimed, e.g. properties. 

An orthogonal solution to my previous goes something like this: 

count 
local N = r(N) 
local OKlist 

foreach v of var rater* { 
	qui count if !missing(`v') 
	if r(N) == `N' { 
		local OKlist `OKlist `V' 
	}
} 

kap `OKlist' 

Here is a pseudocode translation 

count the number of observations 
N <- result of count 
Initialise the list of OK variables to empty 

cycle over variables { 
	count how many non-missing values in that variable 
	if result equals N { 
		add that variable to the list of OK variables 
	}
} 

work with OKlist 

This code could be specialised  e.g. to apply _only_ to obs 1-49: 

count in 1/49 
local N = r(N) 
local OKlist 

foreach v of var rater* { 
	qui count if !missing(`v') in 1/49 
	if r(N) == `N' { 
		local OKlist `OKlist `V' 
	}
}

It would be possible to count missings as well, and include any variable
only if none were present. 

On the useful simplicity of -count-, see 

SJ-7-4  dm0033  . . . . . . Speaking Stata: Counting groups, especially
panels
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
        Q4/07   SJ 7(4):571--581                                 (no
commands)
        discusses how to count panels through reduction commands
        or through tabulation commands and how to overcome
        problems that do not yield easily to these approaches

SJ-7-1  pr0029  . . . . . . . . . . . . . . .  Speaking Stata: Making it
count
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
        Q1/07   SJ 7(1):117--130                                 (no
commands)
        discusses count used with a loop over observations
        or variables

Nick 
n.j.cox@durham.ac.uk 

Frank Gallo

Thank you very much for the reply and the excellent reference. Let me  
start my response with I am a stata beginner. The organization of my  
data table is rows (of variables) and columns (of raters). So your  
syntax creates a rowmiss, which gives the count of missing values  
across variables. What I want to do is exclude the raters (or columns)  
that have missing values on variables (or rows) when calculating kap.  
For example, I have 94 raters: rater1-rater94 columns. I have 49  
variables: p1-p49 rows. If only rater1 and rater2 had missing values  
on variables p1-p49, then I would want to exclude them from kap so  
that I could calculate the test statistics. I do not want to drop them  
from the data, though, because I have other variables such as r1-r15  
for which rater1 and rater2 gave complete ratings. Simply, I want to  
use the set of raters with complete ratings for the variables. I  
greatly appreciate any comments. Thank you.

On Sep 4, 2009, at 1:40 PM, Nick Cox wrote:

egen rowmiss = rowmiss(rater*)
kap rater* if rowmiss == 0

See for a broader discussion

SJ-9-1  pr0046  . . . . . . . . . . . . . . . . . . .  Speaking Stata:
Rowwise
        (help rowsort, rowranks if installed) . . . . . . . . . . .  N.
J. Cox
        Q1/09   SJ 9(1):137--157
        shows how to exploit functions, egen functions, and Mata
        for working rowwise; rowsort and rowranks are introduced

Frank Gallo

I am running the kap command, and I want to limit the analysis to the
raters that gave complete ratings for a set of objects (or variables).
The data matrix is in the form of columns(raters) and rows(variables).
For example:

kap rater1-rater94 if rater1-rater94 != . in 1/49

I know this "does not equal missing" designation here is incorrect,
but it illustrates what I want to do and where I am stuck.

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index