Purpose
This App can be used to calculate the correlation matrix (Pearson, Spearman, and Kendall) between the columns of x matrix and the columns of y matrix.
Operation
- Activate a worksheet. Click the App icon to bring up the dialog.
- Select data range for x and y matrices. If your data is grouped, choose Grouped for Input Data Form and select group range.
- Choose Correlation Type from Pearson, Spearman and Kendall.
- Choose to plot correlation heatmap.
- Click OK to output results.
Sample OPJU File
This app provides a sample OPJU file. Right click the App icon in the Apps Gallery window, and choose Show Samples Folder from the short-cut menu. A folder will open. Drag-and-drop the project file Asymmetric Correlation Matrix Sample.opju from the folder onto Origin. The Notes window in the project shows detailed steps.
Note: If you wish to save the OPJU after changing, it is recommended that you save to a different folder location (e.g. User Files Folder).
Algorithm
Let M1 and M2 be \(n\times n_{x}\) and \(n\times n_{y}\) matrices.
Pearson:
Let A1 and A2 be vectors that average over rows of M1 and M2.
\(\hat{M1}_{ki}=M1_{ki}-A1_{i}\)
\(\hat{M2}_{kj}=M2_{kj}-A2_{j}\)
\(c_{ij}=\frac{1}{n-1} \hat{M1}^{T} \hat{M2}\)
\(S1_{i}= \sqrt{\frac{1}{n-1}\sum_{k=1}^{n}\hat{M1}_{ki}^{2}}\)
\(S2_{j}= \sqrt{\frac{1}{n-1}\sum_{k=1}^{n}\hat{M2}_{kj}^{2}}\)
\(cor_{ij}=\frac{c_{ij}}{S1_{i}S2_{j}}\)
Spearman:
Let MR1 and MR2 be rank matrices(over rows) of M1 and M2. Let A1 and A2 be vectors that average over rows of MR1 and MR2.
\(\hat{M1}_{ki}=MR1_{ki}-A1_{i}\)
\(\hat{M2}_{kj}=MR2_{kj}-A2_{j}\)
\(c_{ij}=\frac{1}{n-1} \hat{M1}^{T} \hat{M2}\)
\(S1_{i}= \sqrt{\frac{1}{n-1}\sum_{k=1}^{n}\hat{M1}_{ki}^{2}}\)
\(S2_{j}= \sqrt{\frac{1}{n-1}\sum_{k=1}^{n}\hat{M2}_{kj}^{2}}\)
\(cor_{ij}=\frac{c_{ij}}{S1_{i}S2_{j}}\)
Kendall:
Let MR1 and MR2 be rank matrices(over rows) of M1 and M2. Let \(m1_{i}\) and \(m2_{j}\) be columns of MR1 and MR2.
\(c_{ij}\)= C-D, where C and D are the number of concordant pairs and the number of discordant pairs of joint random variables \(m1_{i}\) and \(m2_{j}\).
\(S1_{i}= \sqrt{C+D}\), where C and D are the number of concordant pairs and the number of discordant pairs of random variables \(m1_{i}\).
\(S2_{j}= \sqrt{C+D}\), where C and D are the number of concordant pairs and the number of discordant pairs of random variables \(m2_{j}\).
\(cor_{ij}=\frac{c_{ij}}{S1_{i}S2_{j}}\)