Example R programs and commands
17. Kendall's Rank Concordance
# All lines preceded by the "#" character are my comments.
# All other left-justified lines are my input.
# All other indented lines are the R program output.
# Kendall's W, or rank concordance statistic, is not computed by any
# function in R's basic statistics package. It is available as a
# contributed function, which I have placed on the class web site.
#
# Input the definition of kendall.w() by cutting and pasting from
#
# http://www.math.wustl.edu/~victor/classes/ma322/kendall.w.R
#
# (You may need to cut and paste in several pieces.)
# Read some rank data:
# Paper: 1 2 3 4
# ----------------------------------
data<-scan()
4 3 2 1
3 4 2 1
4 3 1 2
3 4 1 2
4 2 1 3
4 2 3 1
dim(data)<-c(4,6) # Coerce the data into a 4x6 matrix, TRANSPOSED!
x <- t(data) # Un-transpose so that the rows have equal sums.
# Call the contributed function, specifying that the numbers in the
# matrix x are ranks:
kendall.w( x, ranks=TRUE )
Kendall's W for ordinal data
W = 0.6 p(table) <0.01