[R] Cohen's Kappa for beginners

matthew.schmidt matthew.schmidt at gmail.com
Wed Feb 9 21:29:44 CET 2011


I'm a newb with R and am trying to move from proprietary stats tools to open
ones. Hopefully this post might help others doing the same.

I downloaded the R package for Mac and hacked together a couple scripts, but
couldn't seem to get the right output. After installing the psych package, I
tried the test script included in this thread on the console, but I got
similar results to a prior poster:

> x
[1] "red"    "yellow" "blue"   "red"   
> y
[1] "red"  "blue" "blue" "red" 
> ck <- cohen.kappa(cbind(x,y))
Error in counts[i, j] <- sum(scores[i, ] == score.levels[j], na.rm = TRUE) : 
  subscript out of bounds
In addition: Warning messages:
1: NAs introduced by coercion 
2: NAs introduced by coercion 

Since I got the impression that there may be a version problem, I updated
the psych package to the most recent version, 1.0-94 (from source). After
this, I tried over and over to run the cohen.kappa command, and still kept
getting the same error.

So I quit R and restarted it, then went to the package manager and selected
the checkbox next to "psych" to load it, and tried to re-run the command.

This time I got the expected output:

Call: cohen.kappa1(x = x, w = w, n.obs = n.obs, alpha = alpha)

Cohen Kappa and Weighted Kappa correlation coefficients and confidence
boundaries 
                  lower estimate upper
unweighted kappa  0.098      0.6  1.10
weighted kappa   -0.693      0.0  0.69

 Number of subjects = 4 

Lesson learned: close and restart the Mac client if you're using the GUI
front-end in order for changes to the package manager to take effect.

-- 
View this message in context: http://r.789695.n4.nabble.com/Cohen-s-Kappa-for-beginners-tp2229658p3298061.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list