2%> This is the base
class for generating objects containing
3%> information about autocorrelation of the input data.<br>
6%> This is convenience
class for easy computation
7%> of autocorrelation and its storage all in one place.<br>
8%> The primary advantage of
this class over the MATLAB
9%> intrinsic functions is in the ability of
this class
10%> to compute the result
for input dataframe table and
11%>
return the results always in MATLAB ``table`` format.<br>
12%> See the documentation of the
class constructor below.<br>
15%> See the documentation of the
class constructor below.<br>
20%> \JoshuaOsborne, May 21 2024, 4:06 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>
25 properties(Access =
public)
29 %> The positive scalar MATLAB whole number representing the
30 %> number of lags
for which the autocorrelation must be computed.<br>
31 %> This argument is directly passed to the corresponding argument
32 %> of the MATLAB intrinsic ``autocorr()`` in the Econometrics Toolbox.<br>
38 %> The positive scalar MATLAB
double representing the
39 %> number of standard deviations to be used in computing the
40 %> lower and upper significance levels of the autocorrelation.<br>
41 %> This argument is directly passed to the corresponding argument
42 %> of the MATLAB intrinsic ``autocorr()`` in the Econometrics Toolbox.<br>
48 %> The MATLAB table of rank ``2`` serving as a convenient
49 %> storage component each column of
which corresponds to the
50 %> absolute ``numstd``-significance bound
for the corresponding
51 %> computed autocorrelations of the input data (that is optionally
52 %> stored in the ``val`` component of the parent
object).<br>
53 %> The values represent the ``numstd``-sigma standard
54 %> errors on the computed autocorrelations.<br>
55 %> Any autocorrelation value bound within these limits can be
56 %> considered random fluctuations at ``numstd``-sigma confidence level.<br>
57 %> This component is automatically populated when constructing
58 %> an
object of
class [pm.stats.AutoCorr](@ref
AutoCorr).<br>
59 %> It must be populated manually at all other times.<br>
65 %> The MATLAB vector integers representing the
66 %> lags
for which the autocorrelation is computed.<br>
67 %> This component is automatically populated when constructing
68 %> an
object of
class [pm.stats.AutoCorr](@ref
AutoCorr).<br>
69 %> It must be populated manually at all other times.<br>
75 %> The MATLAB table of rank ``2`` serving as a
76 %> convenient storage component
for the autocorrelation.<br>
77 %> This component is automatically populated when constructing
78 %> an
object of
class [pm.stats.AutoCorr](@ref
AutoCorr).<br>
79 %> It must be populated manually at all other times.<br>
84 methods(Access =
public)
87 %> Return an
object of
class [pm.stats.AutoCorr](@ref
AutoCorr).<br>
88 %> This is the constructor of the [pm.stats.AutoCorr](@ref
AutoCorr)
class.<br>
90 %> \param[in] df : The input MATLAB matrix or table of rank ``2``
91 %> containing the data as ``ncol`` columns of ``nrow``
92 %> observations whose autocorrelation must be computed.<br>
93 %> (**optional**. If missing, the autocorrelation will not be computed.)
94 %> \param[in] numlag : The input scalar MATLAB positive whole number representing the number
95 %> of lags
for which the autocorrelation must be computed.<br>
96 %> This argument is directly passed to the corresponding argument
97 %> of the MATLAB intrinsic ``autocorr()`` in the Econometrics Toolbox.<br>
98 %> \param[in] numstd : The input positive scalar MATLAB
double representing the
99 %> number of standard deviations to be used in computing the
100 %> lower and upper significance levels of the autocorrelation.<br>
101 %> This argument is directly passed to the corresponding argument
102 %> of the MATLAB intrinsic ``autocorr()`` in the Econometrics Toolbox.<br>
103 %> (**optional**,
default = ``1``)
106 %> ``self`` : The output
object of
class [pm.stats.AutoCorr](@ref
AutoCorr).<br>
112 %> acf = pm.stats.AutoCorr(df)
113 %> acf = pm.stats.AutoCorr(df, numlag)
114 %> acf = pm.stats.AutoCorr(df, [], numstd)
115 %> acf = pm.stats.AutoCorr(df, numlag, numstd)
120 %> \include{lineno} example/stats/
AutoCorr/main.m
127 %> \JoshuaOsborne, May 21 2024, 4:10 AM, University of Texas at Arlington<br>
128 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
129 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
130 function self =
AutoCorr(df, numlag, numstd)
139 numlag = size(df, 1) - 1;
141 [self.val, self.lag, self.bnd] = self.
get(df, numlag, numstd);
143 self.numlag = numlag;
144 self.numstd = numstd;
149 %> Return the autocorrelation of the input
150 %> data from a lag of ``0`` to ``numlag``.<br>
153 %> This is a dynamic method of the [pm.stats.AutoCorr](@ref
AutoCorr)
class.<br>
154 %> This method automatically stores any input information
155 %> in the corresponding components of the parent
object.<br>
156 %> However, any components of the parent
object
157 %> corresponding to the output of
this method
158 %> must be set explicitly manually.<br>
160 %> \param[inout] self : The input/output parent
object of
class [pm.stats.AutoCorr](@ref
AutoCorr)
161 %>
which is **implicitly** passed to
this dynamic method (not by the user).<br>
162 %> \param[in] df : The input MATLAB matrix or table of rank ``2``
163 %> containing the data as ``ncol`` columns of ``nrow``
164 %> observations whose autocorrelation must be computed.<br>
165 %> \param[in] numlag : The input positive scalar MATLAB integer representing the
166 %> number of lags to be used in computing the autocorrelation.<br>
167 %> The
default value will be used
if the input ``numlag``
168 %> is unspecified or empty ``[]``.<br>
169 %> (**optional**,
default = ``size(df, 1) - 1``)
170 %> \param[in] numstd : The input positive scalar MATLAB
double representing the
171 %> number of standard deviations to be used in computing the
172 %> lower and upper significance levels of the autocorrelation.<br>
173 %> This argument is directly passed to the corresponding argument
174 %> of the MATLAB intrinsic ``autocorr()`` in the Econometrics Toolbox.<br>
175 %> The
default value will be used
if the input ``numstd`` is empty ``[]``.<br>
176 %> (**optional**,
default = ``1``)
179 %> ``val`` : The output MATLAB ``table`` of size ``numlag + 1``
180 %> containing the autocorrelation from lag ``0`` to ``numlag``.<br>
181 %> ``lag`` : The output MATLAB ``table`` of size ``numlag + 1``
182 %> containing the autocorrelation lags from ``0`` to ``numlag``.<br>
183 %> ``bnd`` : The output MATLAB ``table`` of ``size(df, 2)`` rows by one column
184 %> containing the absolute ``numstd``-significance level of the
185 %> computed autocorrelations. Any autocorrelation value whose
186 %> magnitude is smaller than the corresponding ``bnd`` element
187 %> can be considered insignificant and mere fluctuation.<br>
192 %> acf = pm.stats.AutoCorr()
193 %> [acf.val, acf.lag, acf.bnd] = acf.get(df)
194 %> [acf.val, acf.lag, acf.bnd] = acf.get(df, [])
195 %> [acf.val, acf.lag, acf.bnd] = acf.get(df, numlag)
196 %> [acf.val, acf.lag, acf.bnd] = acf.get(df, [], numstd)
197 %> [acf.val, acf.lag, acf.bnd] = acf.get(df, numlag, numstd)
202 %> See the documentation of the
class constructor
208 %> \JoshuaOsborne, May 21 2024, 4:14 AM, University of Texas at Arlington<br>
209 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
210 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
211 function [val, lag, bnd] = get(self, df, numlag, numstd)
213 help(
"pm.stats.AutoCorr");
215 +
"The input ``df`` argument is required for computing the autocorrelation." + newline ...
225 self.numlag = numlag;
226 self.numstd = numstd;
228 data = table2array(df);
232 if ~isempty(self.numlag)
233 numlag = self.numlag;
235 numlag = size(data, 1) - 1;
237 val = zeros(numlag + 1, size(data, 2));
238 lag = zeros(numlag + 1, 1);
239 bnd = zeros(size(data, 2), 1);
241 for icol = 1 : size(data, 2)
242 [val(:, icol), lag, bounds] = autocorr(data(:, icol), numlag);
243 bnd(icol) =
abs(bounds(1)) * numstd;
245 val = array2table(val);
247 %val = NaN(numlag, size(data, 2));
248 warning ( newline ...
249 +
string(me.identifier) + " : " +
string(me.message) + newline ...
250 + "skipping the autocorrelation computation..." + newline ...
256 val.Properties.VariableNames = df.Properties.VariableNames;
function abs(in path, in style)
Return the Get absolute canonical path of a file or folder.
This is the base class for generating objects containing information about autocorrelation of the inp...
function AutoCorr(in df, in numlag, in numstd)
Return an object of class pm.stats.AutoCorr. This is the constructor of the pm.stats....
function get(in self, in df, in numlag, in numstd)
Return the autocorrelation of the input data from a lag of 0 to numlag.
This is the base class for generating subclass of MATLAB handle superclass whose annoying methods are...
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...