[R] simple generation of artificial data with defined features

drflxms drflxms at googlemail.com
Sat Aug 23 14:47:03 CEST 2008

Hello Mr. Greg Snow!

Thank you very much for your prompt answer.
> I don't think that the election data is the right data to demonstrate Kappa, you need subjects that are classified by 2 or more different raters/methods.  The election data could be considered classifying the voters into which party they voted for, but you only have 1 rater.
I think, It should be possible to calculate kappa in case one has a
little different point of view from the one you described above: Take
the voters as raters who "judge" the category "election" with one party
out of the six mentioned in my previous e-mail (which are simply the top
This makes sense to me, because an election is somehow nothing else but
a survey with the question "who should lead our country" - given six
options in this example. As kappa is a measure of agreement, it should
be able to illustrate the agreement of the voters answers to this question.
For me this is - in priciple - no different from asking "Where is the
stenosis in the video of this endoscopy" offering six options
representing anatomic locations each.
> Otherwise you may want to stick with the sample datasets.
The example data sets are of excellent quality and very interesting. I
am sure there would be brilliant examples among them. But I have to
admit that,t a I have no t a good overview of the available datasets at
the moment (as a newbie).  I just wanted to give an example out of every
days life, everybody is familiar with. An election is something which
came to my mind spontaneously.
> There are other packages that compute Kappa values as well (I don't know if others calculate this particular version), but some of those take the summary data as input rather than the raw data, which may be easier if you just have the summary tables.
I chose Fleiss Kappa, because it is a more general form of Cohen's Kappa
allowing m raters and n categories (instead of only two raters and to
categories when using Cohen's kappa). Looking for another package
calculating it from summary tables might be the simplest solution to my
problem. Thank you very much for this hint!
On the other hand it would be nice to use the very same method for the
example as for the "real" data. The example will be part of the
"methods" section.

Thank you again very much for your tips and the quick reply. Have a nice
Greetings from Munich,

Felix Mueller-Sarnowski
>> -----Original Message-----
>> From: r-help-bounces at r-project.org
>> [mailto:r-help-bounces at r-project.org] On Behalf Of drflxms
>> Sent: Friday, August 22, 2008 6:12 AM
>> To: r-help at r-project.org
>> Subject: [R] simple generation of artificial data with
>> defined features
>> Dear R-colleagues,
>> I am quite a newbie to R fighting my stupidity to solve a
>> probably quite simple problem of generating artificial data
>> with defined features.
>> I am conducting a study of inter-observer-agreement in
>> child-bronchoscopy. One of the most important measures is
>> Kappa according to Fleiss, which is very comfortable
>> available in R through the irr-package.
>> Unfortunately medical doctors like me don't really understand
>> much of statistics. Therefore I'd like to give the reader an
>> easy understandable example of Fleiss-Kappa in the Methods
>> part. To achieve this, I obtained a table with the results of
>> the German election from 2005:
>> party        number of votes    percent
>> SPD        16194665            34,2
>> CDU        13136740            27,8
>> CSU        3494309            7,4
>> Gruene    3838326            8,1
>> FDP        4648144            9,8
>> PDS        4118194            8,7
>> I want to show the agreement of voters measured by
>> Fleiss-Kappa. To calculate this with the
>> kappam.fleiss-function of irr, I need a data.frame like this:
>>                 (id of 1st voter) (id of 2nd voter)
>> party             spd                         cdu
>> Of course I don't plan to calculate this with the million of
>> cases mentioned in the table above (I am working on a small
>> laptop). A division by 1000 would be more than perfect for
>> this example. The exact format of the table is generally not
>> so important, as I could reshape nearly every format with the
>> help of the reshape-package.
>> Unfortunately I could not figure out how to create such a
>> fictive/artificial dataset as described above. Any data.frame
>> would be nice, that keeps at least the percentage. String-IDs
>> of parties could be substituted by numbers of course (would
>> be even better for function kappam.fleiss in irr!).
>> I would appreciate any kind of help very much indeed.
>> Greetings from Munich,
>> Felix Mueller-Sarnowski
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list