1 |
x |
|
fleiss |
|
w |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x, fleiss = FALSE, w = NULL)
{
if (!is.matrix(x))
stop("x should be a square matrix")
if (ncol(x) != nrow(x))
stop("x should be a square matrix")
p <- dim(x)[2]
x <- as.matrix(x)
tot <- sum(x)
x <- x/tot
rs <- rowSums(x)
cs <- colSums(x)
prob <- rs %*% t(cs)
po <- sum(diag(x))
pc <- sum(diag(prob))
kappa <- (po - pc)/(1 - pc)
if (is.null(w)) {
v = outer(c(1:p), c(1:p), "-")
w = outer(c(1:p), c(1:p), "-")
if (fleiss)
w = 1 - w^2/(p - 1)^2
if (!fleiss)
w = 0.5^abs(w)
}
weighted.prob <- w * prob
weighted.obser <- w * x
wpo <- sum(weighted.obser)
wpc <- sum(weighted.prob)
wkappa <- (wpo - wpc)/(1 - wpc)
return(list(kappa = kappa, weighted.kappa = wkappa))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.