|
1 | 1 | \name{Agree} |
2 | 2 | \alias{Agree} |
| 3 | +\alias{Agree.default} |
| 4 | +\alias{Agree.formula} |
| 5 | + |
3 | 6 | \title{RawSimpleAndExtendedPercentageAgreement} |
4 | 7 | \description{ |
5 | 8 | Computesrawsimpleandextendedpercentageagreementamongraters. |
6 | 9 | } |
7 | 10 | \usage{ |
8 | | -Agree(x,grp=NULL,tolerance=0,na.rm=FALSE) |
| 11 | +Agree(x,...) |
| 12 | +\method{Agree}{formula}(formula,data,subset,na.action, \dots) |
| 13 | +\method{Agree}{default}(x,tolerance=0,na.rm=FALSE,...) |
| 14 | + |
9 | 15 | } |
10 | 16 | \arguments{ |
11 | 17 | \item{x}{adata.frame,alistora \eqn{k \timesm}{kxm}matrix,k subjects (inrows)m raters (incolumns). |
12 | 18 | If \code{grp}isprovideditmustbeavaluevectorofsamelength.} |
13 | | - \item{grp}{agroupingvector,ifthisisprovided,xmustbeasuitablevaluevector.} |
14 | 19 | \item{tolerance}{numberofsuccessiveratingcategoriesthatshouldberegardedasrater agreement (seedetails).} |
15 | 20 | \item{na.rm}{ |
16 | | -logical,indicatingwhether \code{NA}valuesshouldbestrippedbeforethecomputationproceeds.Ifsetto \code{TRUE}onlythecompletecasesoftheratingswillbeused.Defaultsto \code{FALSE}. |
17 | | -%%~~Describe\code{na.rm}here~~ |
| 21 | +logical,indicatingwhether \code{NA}valuesshouldbestrippedbeforethecomputationproceeds. |
| 22 | +Ifsetto \code{TRUE}onlythecompletecasesoftheratingswillbeused.Defaultsto\code{FALSE}. |
18 | 23 | } |
19 | | - |
| 24 | + \item{formula}{aformulaoftheform \code{lhs~rhs}where \code{lhs} |
| 25 | +givesthedatavaluesand \code{rhs}thecorrespondinggroups.} |
| 26 | + \item{data}{anoptionalmatrixordata frame (orsimilar:see |
| 27 | + \code{\link{model.frame}})containingthevariablesinthe |
| 28 | +formula \code{formula}.Bydefaultthevariablesaretakenfrom |
| 29 | + \code{environment(formula)}.} |
| 30 | + \item{subset}{anoptionalvectorspecifyingasubsetofobservations |
| 31 | +tobeused.} |
| 32 | + \item{na.action}{afunctionwhichindicateswhatshouldhappenwhen |
| 33 | +thedatacontain \code{NA}s.Defaultsto |
| 34 | + \code{getOption("na.action")}.} |
20 | 35 |
|
| 36 | + \item{\dots}{furtherargumentstobepassedtoorfrommethods.} |
| 37 | + |
21 | 38 | } |
22 | 39 | \details{ |
23 | 40 | Extendedpercentageagreementcanbecalculatedwitha \code{tolerance>0}.Iftoleranceequals1e.g., |
@@ -89,5 +106,58 @@ Agree(exam[, -1], tolerance=1) |
89 | 106 |
|
90 | 107 | # release difference to max 2, we have 2 agreements (2, 4) |
91 | 108 | Agree(exam[,-1],tolerance=2) |
| 109 | + |
| 110 | + |
| 111 | +# ********************************************************* |
| 112 | +# Operating the Formula Interface |
| 113 | + |
| 114 | +# we have 5 subjects and 4 raters (in wide form) |
| 115 | +(d.ratings<-data.frame( |
| 116 | +subj= c("1","2","3","4","5"), |
| 117 | +rtr1= structure(c(1,1,1,1,3), |
| 118 | +levels= c("V","N","P"),class="factor"), |
| 119 | +rtr2= structure(c(1,2,1,1,3), |
| 120 | +levels= c("V","N","P"),class="factor"), |
| 121 | +rtr3= structure(c(1,3,1,1,3), |
| 122 | +levels= c("V","N","P"),class="factor"), |
| 123 | +rtr4= structure(c(1,1,1,1,2), |
| 124 | +levels= c("V","N","P"),class="factor") |
| 125 | + )) |
| 126 | + |
| 127 | +# this structure can be directly send to the function |
| 128 | +Agree(d.ratings[,-1]) |
| 129 | + |
| 130 | +# or we can coerce to a matrix before (if we want..) |
| 131 | +Agree(as.matrix(d.ratings[,-1])) |
| 132 | + |
| 133 | +# but what, when our structure is in long format? |
| 134 | +d.long<- reshape(d.ratings, |
| 135 | +varying=2:5, |
| 136 | +idvar=c("subj"), |
| 137 | +times=colnames(d.ratings)[2:5], |
| 138 | +v.names="rat",timevar="rater", |
| 139 | +direction="long", |
| 140 | +new.row.names=seq(prod(dim(d.ratings)))) |
| 141 | +head(d.long) |
| 142 | + |
| 143 | +# for that we can use the formulat interface |
| 144 | +# note the structure: response ~ subjects (rows) | raters (columns) |
| 145 | +Agree(rat~subj|rater,d.long) |
| 146 | + |
| 147 | +# but what, when we have missings? |
| 148 | +# we leave out rtr1's rating for subj 2 |
| 149 | + |
| 150 | +# if we do nothing, we clearly get NA |
| 151 | +Agree(rat~subj|rater,d.long[-2,]) |
| 152 | + |
| 153 | +# setting na.action to na.omit omits the subject "1" |
| 154 | +# as reported in attr(,"na.action"), number of subjects is yet 4 |
| 155 | +Agree(rat~subj|rater,d.long[-2,],na.action=na.omit) |
| 156 | + |
| 157 | +# setting na.rm only ignores missings, subject 1 remains in the matrix |
| 158 | +Agree(rat~subj|rater,d.long[-2,],na.rm=TRUE) |
92 | 159 | } |
| 160 | + |
| 161 | + |
| 162 | + |
93 | 163 | \keyword{univar} |