Correlation between 3D matrices and statistics on correlation coefficients

29 visualizaciones (últimos 30 días)
Hi everyone,
I have a question regarding a correlation I need to implement between 3D matrices. I am trying to correlate three 3D matrices (A,B,C) with another 3D matrix of the same dimension (D), separately. I need to run the correlation on the 2nd dimension that for me would be the "time". Once I obtain the correlation coefficients between each of the 3D matrices (A,B,C) and the "test" 3D matrix (D) separately, I want to test which of the 3D matrices returns the highest correlation coefficients with the original matrix (D) and how this changes over time (over columns). I would like to know how, over time, the correlation coefficients change between each of the A,B,C matrices and the original matrix D.
Do you have any idea on which would be the most correct way to implement this?
Thank you very much!!

Respuestas (2)

Divyanshu
Divyanshu el 29 de Ag. de 2023
Hi Arianna,
I understand that you are trying to find correlation coefficients of three 3D matrices A, B, C with a 4th 3D matrix D. And want to know which one of three has maximum correlation with the matrix ‘D’.
Few assumptions that I have made:
  • All the 4 matrices A, B, C, D are of same size.
  • Correlation coefficients are to be determined along the 2nd dimension i.e., along columns.
Based on the above assumptions, here is a sample script which you can refer to:
%create correlation coefficients cell array where each element of array i.e cca{i,j} is
%a square matrix which represents correlation of ith column of matrix P to
%jth column of matrix R
cca = cell(3,10);
ccb = cell(3,10);
ccc = cell(3,10);
% matrixSize is an array that holds the dimensions of the matrices
% Calculate correlation coefficients over time (2nd dimension)
for i=1:matrixSize(3)
for t = 1:matrixSize(2)
cca{i,t} = corrcoef(reshape(A(:, t, :), [], matrixSize(3)), reshape(D(:, t, :), [], matrixSize(3)));
ccb{i,t} = corrcoef(reshape(B(:, t, :), [], matrixSize(3)), reshape(D(:, t, :), [], matrixSize(3)));
ccc{i,t} = corrcoef(reshape(C(:, t, :), [], matrixSize(3)), reshape(D(:, t, :), [], matrixSize(3)));
end
end
%Now just iterate over each of the cell arrays and store all the
%coefficients other than 1 into a vector lets say iterate over cca to
%get a vector coeffA
%Once all 3 vectors are obtained coeffA,coeffB,coeffC just find max for each
%of three and use them according to use-case.
For further details, refer the following documentations:

Adrian
Adrian el 29 de Ag. de 2023
To correlate 3D matrices based on the 2nd dimension (i.e., "time"), you need to treat each "time slice" of the 3D matrix as an individual 2D matrix and compute the correlation for each of those slices. Here are some general approach:
  1. Compute the Correlation for Each Time Slice: For each time slice (column), compute the correlation between matrix D and each of A, B, and C.
  2. Find the Highest Correlation: After computing the correlation for a specific time slice, determine which matrix (A, B, or C) has the highest correlation with D.
  3. Repeat for Each Time Slice: Iterate through each time slice and perform the correlation computation.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by