This is the base class for generating objects with methods and storage components for computing and storing the covariance matrix of an input data.
More...
This is the base class for generating objects with methods and storage components for computing and storing the covariance matrix of an input data.
This is convenience class for easy computation of covariance 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 pm.stats.Cov 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:25 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, July 5 2024, 1:07 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.
Definition at line 23 of file Cov.m.
function Cov::Cov |
( |
in |
df, |
|
|
in |
method |
|
) |
| |
Return an object of class pm.stats.Cov.
This is the constructor of the pm.stats.Cov class.
- Parameters
-
[in] | df | : The input MATLAB matrix or table of rank 2 containing the data as ncol columns of nrow observations whose covariance matrix must be computed.
(optional. If missing, the covariance matrix will not be computed.) |
[in] | method | : The input scalar MATLAB string that can be either:
"pearson" : for computing the Pearson covariance matrix of the input data.
"spearman" : for computing the Spearman rank covariance matrix of the input data.
(optional, default = "pearson" ) |
- Returns
self
: The output object of class pm.stats.Cov.
Possible calling interfaces ⛓
mat = pm.stats.Cov()
mat = pm.stats.Cov(df)
mat = pm.stats.Cov(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.Cov(df); c.val
')
13 c = pm.stats.Cov(df); c.val
16pm.matlab.show('c = pm.stats.Cov(df,
"pearson"); c.val
')
17 c = pm.stats.Cov(df, "pearson"); c.val
20pm.matlab.show('c = pm.stats.Cov(df,
"spearman"); c.val
')
21 c = pm.stats.Cov(df, "spearman"); c.val
24pm.matlab.show('c = pm.stats.Cov(df,
"kendall"); c.val
')
25 c = pm.stats.Cov(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(
"Cov.unifrnd.png",
"-m3");
')
31 p.savefig("Cov.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.Cov(df); c.val
8 Var1 Var2 Var3 Var4 Var5
9 ___________________ __________________ ___________________ __________________ ___________________
10 Var1 0.992674029862441 -0.600871621525417 -0.0957429099298042 0.0105180670415036 -0.549750430720243
11 Var2 -0.600871621525417 1.0162655365192 0.709336259771752 -0.438145638329126 0.641700070376274
12 Var3 -0.0957429099298042 0.709336259771752 1.00670392296548 -0.720832825802482 0.00854336266219076
13 Var4 0.0105180670415036 -0.438145638329126 -0.720832825802482 0.990561807449415 0.34890637083755
14 Var5 -0.549750430720243 0.641700070376274 0.00854336266219076 0.34890637083755 0.999051033438348
16c = pm.stats.Cov(df, "pearson"); c.val
19 Var1 Var2 Var3 Var4 Var5
20 ___________________ __________________ ___________________ __________________ ___________________
21 Var1 0.992674029862441 -0.600871621525417 -0.0957429099298042 0.0105180670415036 -0.549750430720243
22 Var2 -0.600871621525417 1.0162655365192 0.709336259771752 -0.438145638329126 0.641700070376274
23 Var3 -0.0957429099298042 0.709336259771752 1.00670392296548 -0.720832825802482 0.00854336266219076
24 Var4 0.0105180670415036 -0.438145638329126 -0.720832825802482 0.990561807449415 0.34890637083755
25 Var5 -0.549750430720243 0.641700070376274 0.00854336266219076 0.34890637083755 0.999051033438348
27c = pm.stats.Cov(df, "spearman"); c.val
30 Var1 Var2 Var3 Var4 Var5
31 _________________ _________________ _________________ _________________ _________________
32 Var1 2083750 -1211241.07481496 -193492.678135627 26115.4688937788 -1105669.13822765
33 Var2 -1211241.07481496 2083750 1429189.31726345 -877565.067213443 1291280.78255651
34 Var3 -193492.678135627 1429189.31726345 2083750 -1461681.00720144 27399.1730346069
35 Var4 26115.4688937788 -877565.067213443 -1461681.00720144 2083750 697213.572914583
36 Var5 -1105669.13822765 1291280.78255651 27399.1730346069 697213.572914583 2083750
38c = pm.stats.Cov(df, "kendall"); c.val
41 Var1 Var2 Var3 Var4 Var5
42 ___________________ __________________ ___________________ __________________ ___________________
43 Var1 0.992674029862441 -0.600871621525417 -0.0957429099298042 0.0105180670415036 -0.549750430720243
44 Var2 -0.600871621525417 1.0162655365192 0.709336259771752 -0.438145638329126 0.641700070376274
45 Var3 -0.0957429099298042 0.709336259771752 1.00670392296548 -0.720832825802482 0.00854336266219076
46 Var4 0.0105180670415036 -0.438145638329126 -0.720832825802482 0.990561807449415 0.34890637083755
47 Var5 -0.549750430720243 0.641700070376274 0.00854336266219076 0.34890637083755 0.999051033438348
49p = pm.vis.PlotHeatmap(c.val); p.make("precision", 2); p.subplot.setColorLim();
50p.savefig("Cov.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:29 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 Cov::get |
( |
in |
self, |
|
|
in |
df, |
|
|
in |
method |
|
) |
| |
Return the covariance matrix of the input data.
This is a dynamic method of the pm.stats.Cov 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 covariance matrix must be computed.
|
[in] | method | : The input scalar MATLAB string that can be either:
"pearson" : for computing the Pearson covariance matrix of the input data.
"spearman" : for computing the Spearman rank covariance matrix of the input data.
(optional, default = "pearson" ) |
- Returns
val
: The output MATLAB table
containing the covariance matrix.
Possible calling interfaces ⛓
mat = pm.stats.Cov()
mat.val = mat.get(df)
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:31 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