2%> This is the base
class for generating objects with methods
3%> and storage components
for computing and storing the
4%> correlation matrix of an input data.<br>
7%> This is convenience
class for easy computation
8%> of correlation and its storage all in one place.<br>
9%> The primary advantage of
this class over the MATLAB
10%> intrinsic functions is in the ability of
this class
11%> to compute the result
for input dataframe table and
12%>
return the results always in MATLAB ``table`` format.<br>
15%> See the documentation of the
class constructor below.<br>
20%> \JoshuaOsborne, May 21 2024, 4:16 AM, University of Texas at Arlington<br>
21%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
22%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
23classdef
Cor < pm.matlab.Handle
25 properties(Access =
public)
29 %> The scalar MATLAB
string containing the
30 %> method of computing the correlation matrix.<br>
31 %> It can be either:<br>
33 %> <li> ``
"pearson"`` :
for computing the Pearson correlation matrix of the input data.
34 %> <li> ``
"kendall"`` :
for computing the kendall rank correlation matrix of the input data.
35 %> <li> ``
"spearman"`` :
for computing the Spearman rank correlation matrix of the input data.
42 %> The MATLAB table of rank ``2`` serving as a
43 %> convenient storage component
for the correlation matrix.<br>
44 %> This component is automatically populated at the time of
45 %> constructing an
object of
class [pm.stats.Cor](@ref
Cor).<br>
46 %> It must be populated manually at all other times.<br>
51 methods(Access =
public)
54 %> Return an
object of
class ``
Cor``.<br>
57 %> This is the constructor of the ``
Cor``
class.<br>
59 %> \param[in] df : The input MATLAB matrix or table of rank ``2``
60 %> containing the data as ``ncol`` columns of ``nrow``
61 %> observations whose correlation matrix must be computed.<br>
62 %> (**optional**. If missing, the correlation matrix will not be computed.)
64 %> \param[in]
method : The input scalar MATLAB
string that can be either:<br>
66 %> <li> ``
"pearson"`` :
for computing the Pearson correlation matrix of the input data.<br>
67 %> <li> ``
"kendall"`` :
for computing the kendall rank correlation matrix of the input data.<br>
68 %> <li> ``
"spearman"`` :
for computing the Spearman rank correlation matrix of the input data.<br>
70 %> (**optional**,
default = ``
"pearson"``)
73 %> ``self`` : The output
object of
class [pm.stats.Cor](@ref
Cor).
78 %> mat = pm.stats.
Cor()
79 %> mat = pm.stats.Cor(df)
80 %> mat = pm.stats.Cor(df,
method)
85 %> \include{lineno} example/stats/
Cor/main.m
87 %> \include{lineno} example/stats/
Cor/main.out.m
89 %> \image html example/stats/
Cor/
Cor.unifrnd.png width=700
94 %> \JoshuaOsborne, May 21 2024, 4:22 AM, University of Texas at Arlington<br>
95 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
96 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
102 self.val = self.get(df, self.method);
107 %> Return the correlation matrix of the input data.<br>
110 %> This is a dynamic
method of the ``
Cor``
class.
111 %> This
method automatically stores any input information
112 %> in the corresponding components of the parent
object.<br>
113 %> However, any components of the parent
object
114 %> corresponding to the output of
this method
115 %> must be set explicitly manually.<br>
117 %> \param[in] df : The input MATLAB matrix or table of rank ``2``
118 %> containing the data as ``ncol`` columns of ``nrow``
119 %> observations whose correlation matrix must be computed.<br>
121 %> \param[in]
method : The input scalar MATLAB
string that can be either:<br>
123 %> <li> ``
"pearson"`` :
for computing the Pearson correlation matrix of the input data.<br>
124 %> <li> ``
"kendall"`` :
for computing the kendall rank correlation matrix of the input data.<br>
125 %> <li> ``
"spearman"`` :
for computing the Spearman rank correlation matrix of the input data.<br>
127 %> (**optional**,
default = [pm.stats.Cor.method](@ref
Cor::method))
130 %> ``
val`` : The output MATLAB ``table`` containing the correlation matrix.<br>
135 %> mat = pm.stats.Cor()
136 %> mat.val = mat.get(df)
137 %> mat.val = mat.get(df,
method)
142 %> See the documentation of the
class constructor
143 %> [pm.stats.Cor](@ref
Cor::Cor)
for example usage.<br>
148 %> \JoshuaOsborne, May 21 2024, 4:24 AM, University of Texas at Arlington<br>
149 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
150 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
151 function val = get(self, df, method)
153 help(
"pm.stats.Cor");
155 +
"The input ``df`` argument is required for computing the correlation matrix." + newline ...
162 self.method = method;
164 data = table2array(df);
169 val = array2table(corr(data, "type", self.method));
171 val = NaN(size(data, 2), size(data, 2));
172 warning ( newline ...
173 +
string(me.identifier) + " : " +
string(me.message) + newline ...
174 + "skipping the correlation matrix computation..." + newline ...
179 val.Properties.VariableNames = df.Properties.VariableNames;
181 val.Properties.RowNames = val.Properties.VariableNames;
This is the base class for generating objects with methods and storage components for computing and s...
function get(in self, in df, in method)
Return the correlation matrix of the input data.
function Cor(in df, in method)
Return an object of class Cor.
This is the base class for generating subclass of MATLAB handle superclass whose annoying methods are...