1 function [AutoCov,AutoCorr,ARPMX,E,C,s]=invest1(Y,Pmax,D);
2 % First Investigation of a signal (time series) - interactive
3 % [AutoCov,AutoCorr,ARPMX,E,CRITERIA,MOPS]=invest1(Y,Pmax,show);
6 % Pmax maximal order (optional)
7 % show optional; if given the parameters are shown
9 % AutoCov Autocorrelation
10 % AutoCorr normalized Autocorrelation
11 % PartACF Partial Autocorrelation
12 % E Error function E(p)
13 % CRITERIA curves of the various (see below) criteria,
14 % MOPS=[optFPE optAIC optBIC optSBC optMDL optCAT optPHI];
15 % optimal model order according to various criteria
17 % FPE Final Prediction Error (Kay, 1987)
18 % AIC Akaike Information Criterion (Marple, 1987)
19 % BIC Bayesian Akaike Information Criterion (Wei, 1994)
20 % SBC Schwartz's Bayesian Criterion (Wei, 1994)
21 % MDL Minimal Description length Criterion (Marple, 1987)
22 % CAT Parzen's CAT Criterion (Wei, 1994)
23 % PHI Phi criterion (Pukkila et al. 1988)
24 % minE order where E is minimal
27 % P.J. Brockwell and R.A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
28 % S. Haykin "Adaptive Filter Theory" 3ed. Prentice Hall, 1996.
29 % M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
30 % C.E. Shannon and W. Weaver "The mathematical theory of communication" University of Illinois Press, Urbana 1949 (reprint 1963).
31 % W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
33 % optFPE order where FPE is minimal
34 % optAIC order where AIC is minimal
35 % optBIC order where BIC is minimal
36 % optSBC order where SBC is minimal
37 % optMDL order where MDL is minimal
38 % optCAT order where CAT is minimal
39 % optPHI order where PHI is minimal
40 % optRC2 max reflection coefficient larger than std-error
42 % $Id: invest1.m 7687 2010-09-08 18:39:23Z schloegl $
43 % Copyright (C) 1998-2002,2008,2010 by Alois Schloegl <a.schloegl@ieee.org>
44 % This is part of the TSA-toolbox. See also
45 % http://biosig-consulting.com/matlab/tsa/
47 % This program is free software: you can redistribute it and/or modify
48 % it under the terms of the GNU General Public License as published by
49 % the Free Software Foundation, either version 3 of the License, or
50 % (at your option) any later version.
52 % This program is distributed in the hope that it will be useful,
53 % but WITHOUT ANY WARRANTY; without even the implied warranty of
54 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55 % GNU General Public License for more details.
57 % You should have received a copy of the GNU General Public License
58 % along with this program. If not, see <http://www.gnu.org/licenses/>.
62 if nc==1 Y=transpose(Y); nc=nr; nr=1; end;
64 if nargin<2 Pmax=min([100 nc/3]); end;
66 if exist('OCTAVE_VERSION'),
67 fprintf(2,'Warning INVEST1: DIFF-based optimization not possible\n');
68 %%% missing DIM-argument in DIFF.M
70 %tmp=Y-mean(Y,2)*ones(1,nc);
71 RMS(:,1) = mean(Y.^2,2);
74 RMS(:,k+1) = mean(diff(Y,k,2).^2,2);
76 [tmp, orderDIFF] = min(RMS,[],2);
78 % show a nice histogram
79 h = histo3(orderDIFF-1);
80 X = 0:Dmax; H = zeros(1,Dmax+1); for k=1:length(h.X), H(find(X==h.X(k)))=h.H(k); end;
81 %X = 0:Dmax; H = zeros(1,Dmax+1); for k=1:length(x), H(find(X==x(k)))=h(k); end;
88 oD=input('Which order should be used for differentiating [default=0] ?: ');
95 [AutoCov, AutoCorr, ARPMX, E, NC] = invest0(Y,Pmax);
97 [FPE,AIC,BIC,SBC,MDL,CATcrit,PHI,optFPE,optAIC,optBIC,optSBC,optMDL,optCAT,optPHI,s,C] = selmo(E,NC);
100 optRC2=zeros(nr+1,1);
103 optRC2(k+1)=max(find(abs(ARPMX(k,(1:Pmax).*(2:Pmax+1)/2))*sqrt(size(Y,2))>1));
105 optRC2(k+1)=max(find(mean(abs(ARPMX(:,(1:Pmax).*(2:Pmax+1)/2))*sqrt(size(Y,2)),2)>1));
108 %GERSCH=min(find(rc.^2<(0.05/1.05)));
112 %CRITERIA=([FPE;AIC;BIC;SBC;MDL;CATcrit;PHI])';
113 MOPS = s(1:size(s,1),:); %[optFPE optAIC optBIC optSBC optMDL optCAT optPHI];
116 if size(ARPMX,2)==2*Pmax,
117 %invest1(eeg8s,30,'s');
119 RC=ARPMX(:,Pmax+1:2*Pmax);
121 AR=ARPMX(:,Pmax/2*(Pmax-1)+(1:Pmax));
122 RC=ARPMX(:,(1:Pmax).*(2:Pmax+1)/2);