This is the base class for generating objects with methods and storage components for computing and storing the correlation matrix of an input data.
More...
This is the base class for generating objects with methods and storage components for computing and storing the correlation matrix of an input data.
This is convenience class for easy computation of correlation and its storage all in one place.
The primary advantage of this class over the MATLAB intrinsic functions is in the ability of this class to compute the result for input dataframe table and return the results always in MATLAB table
format.
- Note
- See the documentation of the class constructor below.
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
-
If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
-
If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
- Copyright
- Computational Data Science Lab
- Author:
- Joshua Alexander Osborne, May 21 2024, 4:16 AM, University of Texas at Arlington
Fatemeh Bagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.
Amir Shahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin
Definition at line 23 of file Cor.m.
function Cor::Cor |
( |
in |
df, |
|
|
in |
method |
|
) |
| |
Return an object of class Cor
.
This is the constructor of the Cor
class.
- Parameters
-
[in] | df | : The input MATLAB matrix or table of rank 2 containing the data as ncol columns of nrow observations whose correlation matrix must be computed.
(optional. If missing, the correlation matrix will not be computed.) |
[in] | method | : The input scalar MATLAB string that can be either:
-
"pearson" : for computing the Pearson correlation matrix of the input data.
-
"kendall" : for computing the kendall rank correlation matrix of the input data.
-
"spearman" : for computing the Spearman rank correlation matrix of the input data.
(optional, default = "pearson" ) |
- Returns
self
: The output object of class pm.stats.Cor.
Possible calling interfaces ⛓
mat = pm.stats.Cor()
mat = pm.stats.Cor(df)
mat = pm.stats.Cor(df,
method)
Example usage ⛓
1cd(fileparts(mfilename(
'fullpath'))); % Change working directory to source code directory.
2addpath(
'../../../'); % Add the ParaMonte library
root directory to the search path.
4% Make a positive-definite random matrix.
6pm.matlab.show(
"cholow = chol(pm.stats.dist.cov.getRand(5), 'lower');")
7 cholow = chol(pm.stats.dist.cov.getRand(5),
'lower');
8pm.matlab.show(
"df = pm.stats.dist.mvn.getRand(zeros(length(cholow), 1), cholow, 5000)';")
9 df = pm.stats.dist.mvn.getRand(zeros(length(cholow), 1), cholow, 5000)
';
12pm.matlab.show('c = pm.stats.Cor(df); c.val
')
13 c = pm.stats.Cor(df); c.val
16pm.matlab.show('c = pm.stats.Cor(df,
"pearson"); c.val
')
17 c = pm.stats.Cor(df, "pearson"); c.val
20pm.matlab.show('c = pm.stats.Cor(df,
"spearman"); c.val
')
21 c = pm.stats.Cor(df, "spearman"); c.val
24pm.matlab.show('c = pm.stats.Cor(df,
"kendall"); c.val
')
25 c = pm.stats.Cor(df, "kendall"); c.val
28pm.matlab.show('p = pm.vis.PlotHeatmap(c.val); p.make(
"precision", 2); p.subplot.setColorLim();
')
29 p = pm.vis.PlotHeatmap(c.val); p.make("precision", 2); p.subplot.setColorLim();
30pm.matlab.show('p.savefig(
"Cor.unifrnd.png",
"-m3");
')
31 p.savefig("Cor.unifrnd.png", "-m3");
function root()
Return a scalar MATLAB string containing the root directory of the ParaMonte library package.
Example output ⛓
2cholow = chol(pm.stats.dist.cov.getRand(5),
'lower');
3df = pm.stats.dist.mvn.getRand(zeros(length(cholow), 1), cholow, 5000)
';
5c = pm.stats.Cor(df); c.val
8 Var1 Var2 Var3 Var4 Var5
9 _________________ _________________ _________________ _________________ _________________
10 Var1 1 0.999665242214288 0.458249571370196 0.792715437534784 0.516374060655296
11 Var2 0.999665242214288 1 0.442021537667676 0.789882259020928 0.523298427619952
12 Var3 0.458249571370196 0.442021537667675 1 0.111302230708503 0.369318991921761
13 Var4 0.792715437534784 0.789882259020928 0.111302230708503 1 0.144750985785344
14 Var5 0.516374060655296 0.523298427619952 0.369318991921762 0.144750985785344 1
16c = pm.stats.Cor(df, "pearson"); c.val
19 Var1 Var2 Var3 Var4 Var5
20 _________________ _________________ _________________ _________________ _________________
21 Var1 1 0.999665242214288 0.458249571370196 0.792715437534784 0.516374060655296
22 Var2 0.999665242214288 1 0.442021537667676 0.789882259020928 0.523298427619952
23 Var3 0.458249571370196 0.442021537667675 1 0.111302230708503 0.369318991921761
24 Var4 0.792715437534784 0.789882259020928 0.111302230708503 1 0.144750985785344
25 Var5 0.516374060655296 0.523298427619952 0.369318991921762 0.144750985785344 1
27c = pm.stats.Cor(df, "spearman"); c.val
30 Var1 Var2 Var3 Var4 Var5
31 _________________ _________________ _________________ _________________ _________________
32 Var1 1 0.999614926128597 0.441025917961037 0.777405685336228 0.497278984627159
33 Var2 0.999614926128597 1 0.424880785923231 0.774544424133777 0.503945071197803
34 Var3 0.441025917961037 0.424880785923231 1 0.106632464969299 0.359281052995242
35 Var4 0.777405685336228 0.774544424133777 0.106632464969299 1 0.135622407600896
36 Var5 0.497278984627159 0.503945071197803 0.359281052995242 0.135622407600896 1
38c = pm.stats.Cor(df, "kendall"); c.val
41 Var1 Var2 Var3 Var4 Var5
42 _________________ _________________ __________________ __________________ __________________
43 Var1 1 0.983398279655931 0.302229885977195 0.582272774554911 0.344105301060212
44 Var2 0.983398279655931 1 0.290476175235047 0.579331066213243 0.349104380876175
45 Var3 0.302229885977195 0.290476175235047 1 0.0712644928985797 0.24269125825165
46 Var4 0.582272774554911 0.579331066213243 0.0712644928985797 1 0.0910433286657331
47 Var5 0.344105301060212 0.349104380876175 0.24269125825165 0.0910433286657331 1
49p = pm.vis.PlotHeatmap(c.val); p.make("precision", 2); p.subplot.setColorLim();
50p.savefig("Cor.unifrnd.png", "-m3");
Visualization of the example output ⛓
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
-
If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
-
If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
- Copyright
- Computational Data Science Lab
- Author:
- Joshua Alexander Osborne, May 21 2024, 4:22 AM, University of Texas at Arlington
Fatemeh Bagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.
Amir Shahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin
function Cor::get |
( |
in |
self, |
|
|
in |
df, |
|
|
in |
method |
|
) |
| |
Return the correlation matrix of the input data.
This is a dynamic method of the Cor
class. This method automatically stores any input information in the corresponding components of the parent object.
However, any components of the parent object corresponding to the output of this method must be set explicitly manually.
- Parameters
-
[in] | df | : The input MATLAB matrix or table of rank 2 containing the data as ncol columns of nrow observations whose correlation matrix must be computed.
|
[in] | method | : The input scalar MATLAB string that can be either:
-
"pearson" : for computing the Pearson correlation matrix of the input data.
-
"kendall" : for computing the kendall rank correlation matrix of the input data.
-
"spearman" : for computing the Spearman rank correlation matrix of the input data.
(optional, default = pm.stats.Cor.method) |
- Returns
val
: The output MATLAB table
containing the correlation matrix.
Possible calling interfaces ⛓
mat = pm.stats.Cor()
mat.val = mat.get(df)
- Note
- See the documentation of the class constructor pm.stats.Cor for example usage.
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
-
If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
-
If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
- Copyright
- Computational Data Science Lab
- Author:
- Joshua Alexander Osborne, May 21 2024, 4:24 AM, University of Texas at Arlington
Fatemeh Bagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.
Amir Shahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin