Dear Schragi,
There's a function named partial.cor() in the Rcmdr package, but it's so
simple that I'll just reproduce it here:
partial.cor <- function (X, ...)
{
R <- cor(X, ...)
RI <- solve(R)
D <- 1/sqrt(diag(RI))
R <- -RI * (D %o% D)
diag(R) <- 0
rownames(R) <- colnames(R) <- colnames(X)
R
}
Of course, this gives you the partial correlation between each pair of
variables controlling for all others, which is I assume what you want.
I hope this helps,
John
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
On
> Behalf Of Schragi Schwartz
> Sent: March-31-09 5:21 AM
> To: [email protected]
> Cc: 'Dror Hollander'
> Subject: [R] Efficient calculation of partial correlations in R
>
> Hello,
>
> I'm looking for an efficient function for calculating partial
correlations.
> I'm currently using the pcor.test () function, which is equivalent to the
> cor.test() function, and can receive only single vectors as input. I'm
> looking for something which is equivalent to the cor() function, and can
> receive matrixes as input (which should make the calculations much more
> efficient).
>
>
>
> Thanks,
>
> Schragi
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.