Displaying 2 results from an estimated 2 matches for "partialcorr".
2006 Dec 25
1
Higher Dimensional Matrices
Hi all.
I want to calculate partial correlations while controlling for one or more
variables. That works already fine when I control for example just for x[,1]
and x[,2] that gives me one single correlation matrix and i have to to it
for
x [,1]...x[,10]. That would give me out 10 matrices. Controlling for 2
Variables 100 matrices. how
can I run a loop to get f.e the 10 or 100 matrices at once?
2006 Dec 26
1
Colored Dendrogram
...g themselves is
> defined, really.
>
> So how do we do it? Here are a few pointers.
>
> To start, here is a function that uses a somewhat more compact way of
> finding the partial correlations than your method. Sorting out how it
> works should be a useful exercise.
>
> partialCorr <- function (cond, mat)
> cor(qr.resid(qr(cbind(1, mat[, cond])), mat[, -cond]))
>
> To find the matrix of partial correlations conditioning on x[, 1:2]
> you would use
>
> d <- partialCorr(c(1,2), x)
>
> So how to do it for all possible conditioning pairs of va...