Hello, after thorough searching of the R help files as well as S+-help, I'm coming to the list: Is there a possibility to compute partial correlation coefficients between multiple variables (correlation between two paired samples with the "effects of all other variables partialled out")? All I seem to find are the standard Pearson correlation coefficients (with cor()) and no clue as to how to convert them into partial ones. One of my books states that"this is a computionally intensive problem and computer help is most welcome" :-), but fails to give an algorithm. Can anyone help? Maybe this feature already exists somewhere? Cheers Kaspar -- Kaspar Pflugshaupt Geobotanisches Institut Zuerichbergstr. 38 CH-8044 Zuerich Tel. ++41 1 632 43 19 Fax ++41 1 632 12 15 mailto:pflugshaupt at geobot.umnw.ethz.ch privat:pflugshaupt at mails.ch http://www.geobot.umnw.ethz.ch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Kaspar,> to the list: Is there a possibility to compute partial correlation > coefficients between multiple variables (correlation between two pairedI 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))) return(partial) } ******************************************************************** Dr. David Lucy Department of Archaeological Sciences University of Bradford Bradford West Yorkshire BD7 1DP UK 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
At 11:34 AM 2/25/2000 +0100, you wrote:>after thorough searching of the R help files as well as S+-help, I'm coming >to the list: Is there a possibility to compute partial correlation >coefficients between multiple variables (correlation between two paired >samples with the "effects of all other variables partialled out")? All I >seem to find are the standard Pearson correlation coefficients (with cor()) >and no clue as to how to convert them into partial ones. One of my books >states that"this is a computionally intensive problem and computer help is >most welcome" :-), but fails to give an algorithm. Can anyone help? Maybe >this feature already exists somewhere? >Dear Kaspar, Actually, this is quite straightforward. Suppose that R is the correlation matrix among the variables. Then, Rinv<-solve(R) D<-diag(1/sqrt(diag(Rinv))) P<- -D %*% Rinv %*% D The off-diagonal elements of P are then the partial correlations between each pair of variables "partialed" for the others. (Why one would want to do this is another question.) I hope that this helps, John |----------------------------------------------------| | John Fox jfox at McMaster.ca | | Department of Sociology McMaster University | |----------------------------------------------------| -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Seemingly Similar Threads
- Summary: Partial correlation coefficients in R. Thanks everybody!
- Re: [R] R 1.1 congrat; undocumented behaviour of recordPlot (PR#578)
- list of all objects - just being curious
- html documentation bug in: help(par), 'las'
- eqscplot() in library MASS: fails when given only one point (PR#1164)