[R] Re: point-biserial correlation

Noel Yvonnick
Mon, 31 Mar 2003 15:07:00 -0000

> has anyone written a package/function in R for computing a point-
> biserial resp. biserial correlation?

Note that the point-biserial correlation is nothing but the standard
correlation coefficient when one of the variables is dichotomous, so that
cor(.) is OK.

The biserial is different and includes a correction for the so-called
"point
of dichotomy". The following should work (translating a formula found in a
psychometric manual) :

cor.biserial = function(x,y)
{
  stopifnot(is.factor(x))
  stopifnot(length(levels(x))==2)
  stopifnot(length(x)==length(y))

  N = length(y)

  # Success / Failure frequencies
  f = table(x)/length(x)

  # Means of success/failure groups on the global score
  m = tapply(y,x,mean)

  # Variance of the global score
  Sy = sqrt(var(y)*(N-1)/N)

  # Biserial correlation
  # Be cautious in interpreting the sign :
  # depends upon the ordering of levels(x)
  ((m[1]-m[2])/Sy)*(f[1]*f[2]/dnorm(f[1]-.5))

}

Yvonnick Noel, PhD.
Department of Psychology
U. of Lille 3