annotate extra/tsa/inst/invest0.m @ 12580:b6eace8bc216 octave-forge

[tsa] update contact email address
author schloegl
date Thu, 02 Apr 2015 10:00:34 +0000
parents 65a4be217166
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2414
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
1 function [AutoCov,AutoCorr,MX,E,NC]=invest0(Y,Pmax,Mode);
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
2 % First Investigation of a signal (time series) - automated part
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
3 % [AutoCov,AutoCorr,ARPMX,E,ACFsd,NC]=invest0(Y,Pmax);
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
4 %
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
5 % [AutoCov,AutoCorr,ARPMX,E,ACFsd,NC]=invest0(AutoCov,Pmax,Mode);
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
6 %
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
7 %
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
8 % Y time series
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
9 % Pmax maximal order (optional)
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
10 %
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
11 % AutoCov Autocorrelation
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
12 % AutoCorr normalized Autocorrelation
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
13 % PartACF Partial Autocorrelation
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
14 % ARPMX Autoregressive Parameter for order Pmax-1
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
15 % E Error function E(p)
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
16 % NC Number of values (length-missing values)
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
17 %
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
18 % REFERENCES:
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
19 % P.J. Brockwell and R.A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
20 % M.S. Grewal and A.P. Andrews "Kalman Filtering" Prentice Hall, 1993.
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
21 % S. Haykin "Adaptive Filter Theory" 3ed. Prentice Hall, 1996.
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
22 % M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
23 % W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
24
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
25 % $Id$
12580
b6eace8bc216 [tsa] update contact email address
schloegl
parents: 7501
diff changeset
26 % Copyright (C) 1998-2003,2008,2010 by Alois Schloegl <alois.schloegl@gmail.com>
7501
65a4be217166 prepare next release
schloegl
parents: 4907
diff changeset
27 % This is part of the TSA-toolbox. See also
65a4be217166 prepare next release
schloegl
parents: 4907
diff changeset
28 % http://biosig-consulting.com/matlab/tsa/
4907
18ff3d258eea update license of TSA toolbox to GPLv3
schloegl
parents: 4404
diff changeset
29 %
18ff3d258eea update license of TSA toolbox to GPLv3
schloegl
parents: 4404
diff changeset
30 % This program is free software: you can redistribute it and/or modify
18ff3d258eea update license of TSA toolbox to GPLv3
schloegl
parents: 4404
diff changeset
31 % it under the terms of the GNU General Public License as published by
18ff3d258eea update license of TSA toolbox to GPLv3
schloegl
parents: 4404
diff changeset
32 % the Free Software Foundation, either version 3 of the License, or
18ff3d258eea update license of TSA toolbox to GPLv3
schloegl
parents: 4404
diff changeset
33 % (at your option) any later version.
2414
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
34 %
4907
18ff3d258eea update license of TSA toolbox to GPLv3
schloegl
parents: 4404
diff changeset
35 % This program is distributed in the hope that it will be useful,
18ff3d258eea update license of TSA toolbox to GPLv3
schloegl
parents: 4404
diff changeset
36 % but WITHOUT ANY WARRANTY; without even the implied warranty of
18ff3d258eea update license of TSA toolbox to GPLv3
schloegl
parents: 4404
diff changeset
37 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18ff3d258eea update license of TSA toolbox to GPLv3
schloegl
parents: 4404
diff changeset
38 % GNU General Public License for more details.
2414
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
39 %
4907
18ff3d258eea update license of TSA toolbox to GPLv3
schloegl
parents: 4404
diff changeset
40 % You should have received a copy of the GNU General Public License
18ff3d258eea update license of TSA toolbox to GPLv3
schloegl
parents: 4404
diff changeset
41 % along with this program. If not, see <http://www.gnu.org/licenses/>.
2414
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
42
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
43 if nargin<3
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
44 Mode=0;
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
45 else
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
46 Mode=1;
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
47 end;
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
48
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
49 [nr,nc]=size(Y);
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
50 NC = sumskipnan(real(~isnan(Y)),2); % number of valid components (data points)
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
51
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
52 if Mode==0
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
53 if nargin<2, Pmax = min([100 nc/3]); end;
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
54 M = min(Pmax,nc-1);
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
55 AutoCov = acovf(Y,M);
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
56 else
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
57 AutoCov=Y;
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
58 M = min(Pmax,nc-1);
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
59 nc = Pmax;
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
60 %M=size(AutoCov,2)-1;
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
61 end;
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
62
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
63 AutoCorr = AutoCov(:,2:M+1)./AutoCov(:,ones(M,1));
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
64
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
65 if 1,Pmax<100; % this needs change of sinvest1
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
66 K=M-1;
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
67 [MX,E]=lattice(Y,Pmax);
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
68 %[MX,E]=ulsar(Y,Pmax);
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
69 %[MX,E]=durlev(AutoCov);
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
70 % ARP=MX(:,K*(K-1)/2+(1:K));
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
71 % PartACF =MX(:,(1:K).*(2:K+1)/2);
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
72 else %if nargout > 2
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
73 [ARP,RC,E]=lattice(Y,Pmax);
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
74 %[ARP,PartACF,E]=durlev(AutoCov);
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
75 %MX=[ARP,RC];
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
76 end;
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
77
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
78
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
79
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
80
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
81
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
82
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
83
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
84
19251cd2753b Latest package manager mega patch, but not the last
adb014
parents:
diff changeset
85