[R] Cohen's Kappa for beginners

David Winsemius dwinsemius at comcast.net
Thu Feb 10 04:20:24 CET 2011


On Feb 9, 2011, at 3:29 PM, matthew.schmidt wrote:

>
> 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

Posted to the wrong list.

> 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.

I have a small screenshot for you to look at:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Refresh.list.pdf
Type: application/pdf
Size: 14331 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110209/af4185b4/attachment.pdf>
-------------- next part --------------




David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list