`phi(t, digits = 2)`

t

a 1 x 4 vector or a 2 x 2 matrix

digits

round the result to digits

- phi coefficient of correlation

The calculation follows J. Wiggins discussion of personality assessment.

`phi2poly`

phi(c(30,20,20,30)) phi(c(40,10,10,40)) x <- matrix(c(40,5,20,20),ncol=2) phi(x) ## The function is currently defined as function(t,digits=2) { # expects: t is a 2 x 2 matrix or a vector of length(4) stopifnot(prod(dim(t)) == 4 || length(t) == 4) if(is.vector(t)) t <- matrix(t, 2) r.sum <- rowSums(t) c.sum <- colSums(t) total <- sum(r.sum) r.sum <- r.sum/total c.sum <- c.sum/total v <- prod(r.sum, c.sum) phi <- (t[1,1]/total - c.sum[1]*r.sum[1]) /sqrt(v) return(round(phi,2)) }