[R] partial correlation coefficients in R?

Dave Lucy D.J.Lucy at Bradford.ac.uk
Fri Feb 25 12:58:07 CET 2000


> to the list: Is there a possibility to compute partial correlation
> coefficients between multiple variables (correlation between two paired

I use this for partialing the three variable case, if you find any which
will handle more varibles let me know:

# pcor - partial correlation routine invoked by tspcor and the like
# calculates the partial correlation coefficient between v1 and v2
# controlling for v3 - returns that value

pcor <- function(v1, v2, v3)
	c12 <- cor(v1, v2)
	c23 <- cor(v2, v3)
	c13 <- cor(v1, v3)

	partial <- (c12-(c13*c23))/(sqrt(1-(c13^2)) * sqrt(1-(c23^2)))


Dr. David Lucy
Department of Archaeological Sciences
University of Bradford
West Yorkshire

tel. +44 01274 233556
fax. +44 01274 235190

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list