# Sample data:
V <- c(1,1,1,1,2,3,3,3,3,4,4,4,4,4,4)
# calculate agreement; using collapse() to create the frequency vector
agreement(collapse(V))
# Calculate agreement A with coding error:
agreementError(V)
# Assume that all values could have coding error:
agreementError(V, e=1)
# Run the function a few times and show the mean:
z <- replicate(1000, agreementError(V))
mean(z)
hist(z) # etc.
# the example mentioned, population vector [3 0 0 0 0]:
V2 <- c(1,1,1)
agreementError(V2, pos=1:5)
# you can also use the compareAgreement function
compareAgreement(V2, pos=1:5)
Run the code above in your browser using DataLab