Reputation: 23
I am wondering how to find r, the correlation coefficient for a contingency table of an ordinal dataset. My text gives the following formula: formula attached
Is there an R package or function that does this calculation?
For example, if my table was
T <- as.table(rbind(
c(9, 44, 13, 10),
c(11, 52, 23, 22),
c(9, 41, 12, 27)))
dimnames(T) <- list(Var1 = c("A","B","C"),
Var2 = c("W","X","Y","Z"))
Can R calculate r of this example data set for me quickly? The answer in this case should be r = 0.14
Upvotes: 1
Views: 434
Reputation: 1994
the polycor
R package should be able to get to the correct solution:
T
## Var2
## Var1 W X Y Z
## A 9 44 13 10
## B 11 52 23 22
## C 9 41 12 27
# install.packages("polycor")
library(polycor)
polychor(T)
## [1] 0.148935
Upvotes: 1