From: Jokel Meyer on
Dear Matlab experts!
I tried to use partialcorr command to create a partial correlation
matrix. I
created a loop to calculated all the partial correlations in
my matrix (number of rows as observations, number of columns as
variables to correlate). First it seemed to work fine, however I
thought as the partialcorr command required transposing my martix,
the
calculation of a partial correlation should not be possible if i have
more variables than number of observations in my original martix.
However my code does not result in an error message when I calculate
the partial correlation matrix from a original martix with more
variables than observations.
In addition to that some diagonal elements of the resulting partial
correlation matrix do not show the expected 1 (correlation of a
variable with itself); what makes me doubt that i coded without
mistakes!
Also i receive lots of warnings, that i am not sure where they are
coming from:
> In partialcorr at 193

Warning: Rank deficient, rank = 108, tol = 4.7992e-10.


Here is my code:

m=size(mymatrix);
X=mymatrx;
R = eye(m);
for i = 1:m
for j = 1:i-1
k = setdiff(1:m,[i j]);
R(i,j) = partialcorr(X(:,i),X(:,j),X(:,k)); R(j,i) = R(i,j);
end
end


Grateful for any help!